diff --git a/AudioCuesheetEditor/AudioCuesheetEditor.csproj b/AudioCuesheetEditor/AudioCuesheetEditor.csproj index caae1e57..1f86a34b 100644 --- a/AudioCuesheetEditor/AudioCuesheetEditor.csproj +++ b/AudioCuesheetEditor/AudioCuesheetEditor.csproj @@ -97,7 +97,6 @@ - diff --git a/AudioCuesheetEditor/Model/IO/Audio/AudioConverterService.cs b/AudioCuesheetEditor/Model/IO/Audio/AudioConverterService.cs deleted file mode 100644 index 2aa9edaf..00000000 --- a/AudioCuesheetEditor/Model/IO/Audio/AudioConverterService.cs +++ /dev/null @@ -1,118 +0,0 @@ -//This file is part of AudioCuesheetEditor. - -//AudioCuesheetEditor is free software: you can redistribute it and/or modify -//it under the terms of the GNU General Public License as published by -//the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. - -//AudioCuesheetEditor is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. - -//You should have received a copy of the GNU General Public License -//along with Foobar. If not, see -//. -using FFmpegBlazor; -using Microsoft.JSInterop; - -namespace AudioCuesheetEditor.Model.IO.Audio -{ - public class AudioConverterService : IAudioConverterService, IDisposable - { - private readonly IJSRuntime _jSRuntime; - private FFMPEG? ffMPEGInstance; - private bool disposedValue; - - public event EventHandler? ProgressChanged; - - public AudioConverterService(IJSRuntime jSRuntime) - { - _jSRuntime = jSRuntime; - } - - public void Dispose() - { - // Ändern Sie diesen Code nicht. Fügen Sie Bereinigungscode in der Methode "Dispose(bool disposing)" ein. - Dispose(disposing: true); - GC.SuppressFinalize(this); - } - - public Boolean IsReady => (ffMPEGInstance != null) && ffMPEGInstance.IsLoaded; - - public async Task SplitAudiofileAsync(Audiofile audiofile, TimeSpan from, TimeSpan? to = null) - { - if (IsReady == false) - { - await InitAsync(); - } - if (ffMPEGInstance != null) - { - await audiofile.LoadContentStream(); - if (audiofile.ContentStream != null) - { - using var memoryStream = new MemoryStream(); - audiofile.ContentStream.Seek(0, SeekOrigin.Begin); - audiofile.ContentStream.CopyTo(memoryStream); - var buffer = memoryStream.ToArray(); - ffMPEGInstance.WriteFile(audiofile.Name, buffer); - var splitAudiofilename = String.Format("output-{0}{1}", Guid.NewGuid(), audiofile.AudioCodec?.FileExtension); - if (to == null) - { - await ffMPEGInstance.Run("-ss", from.ToString("hh\\:mm\\:ss\\.fff"), "-i", audiofile.Name, "-c", "copy", splitAudiofilename); - } - else - { - await ffMPEGInstance.Run("-ss", from.ToString("hh\\:mm\\:ss\\.fff"), "-i", audiofile.Name, "-to", to.Value.ToString("hh\\:mm\\:ss\\.fff"), "-c", "copy", splitAudiofilename); - } - ffMPEGInstance.UnlinkFile(audiofile.Name); - var res = await ffMPEGInstance.ReadFile(splitAudiofilename); - return res; - } - else - { - throw new Exception("ContentStream wasn't loaded!"); - } - } - return null; - } - - public async Task InitAsync() - { - //initialize FFmpegFactory - await FFmpegFactory.Init(_jSRuntime); - if (ffMPEGInstance == null) - { - ffMPEGInstance = FFmpegFactory.CreateFFmpeg(new FFmpegConfig() { Log = true }); - await ffMPEGInstance.Load(true); - - ffMPEGInstance.Progress += FFMPEGInstance_Progress; - } - } - - protected virtual void Dispose(bool disposing) - { - if (!disposedValue) - { - if (disposing) - { - // Verwalteten Zustand (verwaltete Objekte) bereinigen - if (ffMPEGInstance != null) - { - ffMPEGInstance.Progress -= FFMPEGInstance_Progress; - } - - } - - // Nicht verwaltete Ressourcen (nicht verwaltete Objekte) freigeben und Finalizer überschreiben - // Große Felder auf NULL setzen - disposedValue = true; - } - } - - private void FFMPEGInstance_Progress(Progress p) - { - ProgressChanged?.Invoke(this, Convert.ToInt32(p.Ratio * 100)); - } - } -} diff --git a/AudioCuesheetEditor/Model/IO/Audio/IAudioConverterService.cs b/AudioCuesheetEditor/Model/IO/Audio/IAudioConverterService.cs deleted file mode 100644 index b060702d..00000000 --- a/AudioCuesheetEditor/Model/IO/Audio/IAudioConverterService.cs +++ /dev/null @@ -1,23 +0,0 @@ -//This file is part of AudioCuesheetEditor. - -//AudioCuesheetEditor is free software: you can redistribute it and/or modify -//it under the terms of the GNU General Public License as published by -//the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. - -//AudioCuesheetEditor is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. - -//You should have received a copy of the GNU General Public License -//along with Foobar. If not, see -//. -namespace AudioCuesheetEditor.Model.IO.Audio -{ - public interface IAudioConverterService - { - public event EventHandler? ProgressChanged; - public Task SplitAudiofileAsync(Audiofile audiofile, TimeSpan from, TimeSpan? to = null); - } -} diff --git a/AudioCuesheetEditor/Model/IO/Export/ExportAudiofile.cs b/AudioCuesheetEditor/Model/IO/Export/ExportAudiofile.cs deleted file mode 100644 index e4544286..00000000 --- a/AudioCuesheetEditor/Model/IO/Export/ExportAudiofile.cs +++ /dev/null @@ -1,23 +0,0 @@ -//This file is part of AudioCuesheetEditor. - -//AudioCuesheetEditor is free software: you can redistribute it and/or modify -//it under the terms of the GNU General Public License as published by -//the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. - -//AudioCuesheetEditor is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. - -//You should have received a copy of the GNU General Public License -//along with Foobar. If not, see -//. -namespace AudioCuesheetEditor.Model.IO.Export -{ - public class ExportAudiofile - { - public string? Name { get; set; } - public byte[]? Content { get; set; } - } -} diff --git a/AudioCuesheetEditor/Model/IO/Export/Exportfile.cs b/AudioCuesheetEditor/Model/IO/Export/Exportfile.cs index 64b6792b..154a3af4 100644 --- a/AudioCuesheetEditor/Model/IO/Export/Exportfile.cs +++ b/AudioCuesheetEditor/Model/IO/Export/Exportfile.cs @@ -23,6 +23,5 @@ public class Exportfile public byte[]? Content { get; set; } public TimeSpan? Begin { get; set; } public TimeSpan? End { get; set; } - public ExportAudiofile? ExportAudiofile { get; set; } } } diff --git a/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs b/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs index 1d155901..ac3a4a5b 100644 --- a/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs +++ b/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs @@ -35,20 +35,19 @@ public class ExportfileGenerator : Validateable public Cuesheet Cuesheet { get; } public Exportprofile? Exportprofile { get; set; } public ApplicationOptions? ApplicationOptions { get; set; } - public IAudioConverterService? AudioConverterService { get; set; } public ExportType ExportType { get; set; } - public ExportfileGenerator(ExportType exportType, Cuesheet cuesheet, Exportprofile? exportprofile = null, ApplicationOptions? applicationOptions = null, IAudioConverterService? audioConverterService = null) + public ExportfileGenerator(ExportType exportType, Cuesheet cuesheet, Exportprofile? exportprofile = null, ApplicationOptions? applicationOptions = null) { ExportType = exportType; Cuesheet = cuesheet; Exportprofile = exportprofile; ApplicationOptions = applicationOptions; - AudioConverterService = audioConverterService; } - public async Task> GenerateExportfilesAsync() + public IReadOnlyCollection GenerateExportfiles() { + //TODO: Generate export files with start 00:00:00 and each end set correctly! List exportfiles = new(); if (Validate().Status != ValidationStatus.Error) { @@ -80,8 +79,7 @@ public async Task> GenerateExportfilesAsync() } if (content != null) { - var exportAudiofile = await GetAudiofileContentAsync(audioFileName, previousSplitPointMoment, splitPoint); - exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = previousSplitPointMoment, End = splitPoint.Moment, ExportAudiofile = exportAudiofile }); + exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = previousSplitPointMoment, End = splitPoint.Moment }); } previousSplitPointMoment = splitPoint.Moment; counter++; @@ -105,8 +103,7 @@ public async Task> GenerateExportfilesAsync() } if (content != null) { - var exportAudiofile = await GetAudiofileContentAsync(audioFileName, previousSplitPointMoment); - exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = previousSplitPointMoment, ExportAudiofile = exportAudiofile }); + exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = previousSplitPointMoment }); } } else @@ -315,38 +312,6 @@ private String WriteExport(String audiofileName, TimeSpan? from = null, SplitPoi return builder.ToString(); } - private async Task GetAudiofileContentAsync(String audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null) - { - ExportAudiofile? exportAudiofile = null; - if ((from != null) || (splitPoint != null)) - { - TimeSpan start = TimeSpan.Zero; - if (from != null) - { - start = from.Value; - } - else - { - var minBegin = Cuesheet.Tracks.Min(x => x.Begin); - if (minBegin != null) - { - start = minBegin.Value; - } - } - if (AudioConverterService == null) - { - throw new NullReferenceException(); - } - if (Cuesheet.Audiofile == null) - { - throw new NullReferenceException(); - } - var content = await AudioConverterService.SplitAudiofileAsync(Cuesheet.Audiofile, start, splitPoint?.Moment); - exportAudiofile = new() { Name = audiofileName, Content = content }; - } - return exportAudiofile; - } - protected override ValidationResult Validate(string property) { ValidationResult validationResult; @@ -414,27 +379,6 @@ protected override ValidationResult Validate(string property) validationResult = ValidationResult.Create(ValidationStatus.NoValidation); } break; - case nameof(AudioConverterService): - if (Cuesheet.SplitPoints.Any()) - { - if (AudioConverterService == null) - { - var validationMessages = new List() - { - new("{0} has no value!", nameof(Exportprofile)) - }; - validationResult = ValidationResult.Create(ValidationStatus.Error, validationMessages); - } - else - { - validationResult = ValidationResult.Create(ValidationStatus.Success); - } - } - else - { - validationResult = ValidationResult.Create(ValidationStatus.NoValidation); - } - break; default: validationResult = ValidationResult.Create(ValidationStatus.NoValidation); break; diff --git a/AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs b/AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs index 456fd0f7..15a332e4 100644 --- a/AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs +++ b/AudioCuesheetEditor/Model/IO/Export/SplitPoint.cs @@ -22,6 +22,7 @@ namespace AudioCuesheetEditor.Model.IO.Export { public class SplitPoint : Validateable, ITraceable { + //TODO: Add audio file name as property to be set by user private Cuesheet? cuesheet; private TimeSpan? moment; private String? artist; diff --git a/AudioCuesheetEditor/Program.cs b/AudioCuesheetEditor/Program.cs index 122fd599..45bdad06 100644 --- a/AudioCuesheetEditor/Program.cs +++ b/AudioCuesheetEditor/Program.cs @@ -52,7 +52,6 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); -builder.Services.AddScoped(); builder.Services.AddLogging(); builder.Logging.AddConfiguration(builder.Configuration.GetSection("Logging")); diff --git a/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/de.json b/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/de.json index 8f6b5874..2709c8c3 100644 --- a/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/de.json +++ b/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/de.json @@ -7,7 +7,6 @@ "Begin": "Anfang", "End": "Ende", "Content": "Inhalt", - "ExportAudiofile": "Verarbeitete Audiodatei", "Download this file": "Diese Datei herunterladen", "Generate export files": "Exportdateien generieren", "Abort": "Abbrechen", diff --git a/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/en.json b/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/en.json index 0636febf..973e4b8a 100644 --- a/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/en.json +++ b/AudioCuesheetEditor/Resources/Localization/ModalExportdialog/en.json @@ -7,7 +7,6 @@ "Begin": "Begin", "End": "End", "Content": "Content", - "ExportAudiofile": "Split audiofile", "Download this file": "Download this file", "Generate export files": "Generate export files", "Abort": "Abort", diff --git a/AudioCuesheetEditor/Shared/MainLayout.razor b/AudioCuesheetEditor/Shared/MainLayout.razor index f2449c96..1e8fe17a 100644 --- a/AudioCuesheetEditor/Shared/MainLayout.razor +++ b/AudioCuesheetEditor/Shared/MainLayout.razor @@ -31,7 +31,6 @@ along with Foobar. If not, see @inject SessionStateContainer _sessionStateContainer @inject IBlazorDownloadFileService _blazorDownloadFileService @inject ITextLocalizer _validationMessageLocalizer -@inject IAudioConverterService _audioConverterService @@ -419,7 +418,7 @@ along with Foobar. If not, see { get { - var generator = new ExportfileGenerator(ExportType.Cuesheet, _sessionStateContainer.Cuesheet, applicationOptions: applicationOptions, audioConverterService: _audioConverterService); + var generator = new ExportfileGenerator(ExportType.Cuesheet, _sessionStateContainer.Cuesheet, applicationOptions: applicationOptions); var validationResult = generator.Validate(); if (validationResult.Status == Model.Entity.ValidationStatus.Error) { diff --git a/AudioCuesheetEditor/Shared/ModalExportdialog.razor b/AudioCuesheetEditor/Shared/ModalExportdialog.razor index 9318493f..10d8231f 100644 --- a/AudioCuesheetEditor/Shared/ModalExportdialog.razor +++ b/AudioCuesheetEditor/Shared/ModalExportdialog.razor @@ -24,7 +24,6 @@ along with Foobar. If not, see @inject SessionStateContainer _sessionStateContainer @inject IBlazorDownloadFileService _blazorDownloadFileService @inject HotKeys _hotKeys -@inject IAudioConverterService _audioConverterService @@ -54,10 +53,6 @@ along with Foobar. If not, see @_localizer[nameof(Exportfile.Begin)] @_localizer[nameof(Exportfile.End)] @_localizer[nameof(Exportfile.Content)] - @if ((exportfiles != null) && (exportfiles.Any(x => x.ExportAudiofile != null))) - { - @_localizer[nameof(Exportfile.ExportAudiofile)] - } @@ -79,19 +74,6 @@ along with Foobar. If not, see - @if (exportfile.ExportAudiofile != null) - { - - - - - - } } } @@ -128,6 +110,7 @@ along with Foobar. If not, see @code { + //TODO: Export of cuesheet doesn't work (ApplicationOptions missing in ExportfileGenerator) public event EventHandler? GenerateExportfilesClicked; [Parameter] @@ -214,15 +197,13 @@ along with Foobar. If not, see hotKeysContext = _hotKeys.CreateContext() .Add(Key.Enter, OnEnterKeyDown); - _audioConverterService.ProgressChanged += IAudioConverterService_ProgressChanged; - ExportfileGenerator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet, audioConverterService: _audioConverterService); + ExportfileGenerator = new ExportfileGenerator(ExportType, _sessionStateContainer.Cuesheet); await base.OnInitializedAsync(); } public void Dispose() { - _audioConverterService.ProgressChanged -= IAudioConverterService_ProgressChanged; hotKeysContext?.Dispose(); } @@ -252,7 +233,7 @@ along with Foobar. If not, see } } - async Task GenerateExportfiles_Clicked() + Task GenerateExportfiles_Clicked() { _logger.LogDebug("GenerateExportfiles_Clicked called"); if (ExportPossible) @@ -261,12 +242,13 @@ along with Foobar. If not, see exportProgress = 0; if (ExportfileGenerator != null) { - exportfiles = await ExportfileGenerator.GenerateExportfilesAsync(); + exportfiles = ExportfileGenerator.GenerateExportfiles(); selectedStep = "displayExportResult"; prepareExportCompleted = true; } exportProgress = null; } + return Task.CompletedTask; } bool NavigationAllowed(StepNavigationContext context) diff --git a/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs b/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs index a58f4c74..79bcb516 100644 --- a/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs +++ b/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs @@ -34,7 +34,7 @@ public class ExportfileGeneratorTests { [TestMethod()] - public async Task GenerateCuesheetFilesTestAsync() + public void GenerateCuesheetFilesTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -57,7 +57,7 @@ public async Task GenerateCuesheetFilesTestAsync() cuesheet.AddTrack(track, testHelper.ApplicationOptions); } var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); Assert.AreEqual(Exportfile.DefaultCuesheetFilename, generatedFiles.First().Name); var content = generatedFiles.First().Content; @@ -83,7 +83,7 @@ public async Task GenerateCuesheetFilesTestAsync() File.Delete(fileName); cuesheet.CDTextfile = new CDTextfile("Testfile.cdt"); cuesheet.Cataloguenumber.Value = "0123456789123"; - generatedFiles = await generator.GenerateExportfilesAsync(); + generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); content = generatedFiles.First().Content; Assert.IsNotNull(content); @@ -96,12 +96,12 @@ public async Task GenerateCuesheetFilesTestAsync() cuesheet.CDTextfile = new CDTextfile("Testfile.cdt"); cuesheet.Cataloguenumber.Value = "Testvalue"; Assert.AreEqual(ValidationStatus.Error, generator.Validate().Status); - generatedFiles = await generator.GenerateExportfilesAsync(); + generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(0, generatedFiles.Count); } [TestMethod()] - public async Task GenerateCuesheetFilesWithPreGapAndPostGapTestAsync() + public void GenerateCuesheetFilesWithPreGapAndPostGapTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -132,7 +132,7 @@ public async Task GenerateCuesheetFilesWithPreGapAndPostGapTestAsync() cuesheet.AddTrack(track, testHelper.ApplicationOptions); } var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); var content = generatedFiles.First().Content; Assert.IsNotNull(content); @@ -165,7 +165,7 @@ public async Task GenerateCuesheetFilesWithPreGapAndPostGapTestAsync() } [TestMethod()] - public async Task GenerateCuesheetFilesWithTrackFlagsTestAsync() + public void GenerateCuesheetFilesWithTrackFlagsTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -194,7 +194,7 @@ public async Task GenerateCuesheetFilesWithTrackFlagsTestAsync() cuesheet.AddTrack(track, testHelper.ApplicationOptions); } var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); var content = generatedFiles.First().Content; Assert.IsNotNull(content); @@ -221,7 +221,7 @@ public async Task GenerateCuesheetFilesWithTrackFlagsTestAsync() } [TestMethod()] - public async Task GenerateCuesheetFilesWithIncorrectTrackPositionsTestAsync() + public void GenerateCuesheetFilesWithIncorrectTrackPositionsTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -254,7 +254,7 @@ public async Task GenerateCuesheetFilesWithIncorrectTrackPositionsTestAsync() cuesheet.Tracks.ElementAt(3).Position = 4; cuesheet.Tracks.ElementAt(4).Position = 5; Assert.AreEqual(ValidationStatus.Success, generator.Validate().Status); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); var content = generatedFiles.First().Content; Assert.IsNotNull(content); @@ -280,7 +280,7 @@ public async Task GenerateCuesheetFilesWithIncorrectTrackPositionsTestAsync() } [TestMethod()] - public async Task GenerateCuesheetFilesWithSplitPointsTestAsync() + public void GenerateCuesheetFilesWithSplitPointsTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -315,9 +315,9 @@ public async Task GenerateCuesheetFilesWithSplitPointsTestAsync() splitPoint.Title = "Title 3"; splitPoint.Moment = new TimeSpan(1, 30, 0); testHelper.ApplicationOptions.CuesheetFilename = "Unit test.cue"; - var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions, audioConverterService:testHelper.AudioConverterService); + var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions); Assert.AreEqual(ValidationStatus.Success, generator.Validate().Status); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(5, generatedFiles.Count); var position = 1; var counter = 1; @@ -381,9 +381,9 @@ public async Task GenerateCuesheetFilesWithSplitPointsTestAsync() position--; } } - + [TestMethod()] - public async Task GenerateExportfilesTestAsync() + public void GenerateExportfilesTest() { var testHelper = new TestHelper(); //Prepare cuesheet @@ -428,7 +428,7 @@ public async Task GenerateExportfilesTestAsync() }; Assert.AreEqual(ValidationStatus.Success, exportProfile.Validate().Status); var generator = new ExportfileGenerator(ExportType.Exportprofile, cuesheet, exportprofile: exportProfile); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); Assert.AreEqual(exportProfile.Filename, generatedFiles.First().Name); var fileContent = generatedFiles.First().Content; @@ -461,7 +461,7 @@ public async Task GenerateExportfilesTestAsync() }; Assert.AreEqual(ValidationStatus.Success, exportProfile.Validate().Status); generator.Exportprofile = exportProfile; - generatedFiles = await generator.GenerateExportfilesAsync(); + generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); Assert.AreEqual(exportProfile.Filename, generatedFiles.First().Name); fileContent = generatedFiles.First().Content; @@ -495,7 +495,7 @@ public async Task GenerateExportfilesTestAsync() }; Assert.AreEqual(ValidationStatus.Success, exportProfile.Validate().Status); generator.Exportprofile = exportProfile; - generatedFiles = await generator.GenerateExportfilesAsync(); + generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); Assert.AreEqual(exportProfile.Filename, generatedFiles.First().Name); fileContent = generatedFiles.First().Content; @@ -520,7 +520,7 @@ public async Task GenerateExportfilesTestAsync() } [TestMethod()] - public async Task GenerateExportfilesWithPregapAndPostgapTestAsync() + public void GenerateExportfilesWithPregapAndPostgapTest() { var testHelper = new TestHelper(); //Prepare cuesheet @@ -566,7 +566,7 @@ public async Task GenerateExportfilesWithPregapAndPostgapTestAsync() }; Assert.AreEqual(ValidationStatus.Success, exportProfile.Validate().Status); var generator = new ExportfileGenerator(ExportType.Exportprofile, cuesheet, exportprofile: exportProfile); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(1, generatedFiles.Count); Assert.AreEqual(exportProfile.Filename, generatedFiles.First().Name); var fileContent = generatedFiles.First().Content; @@ -586,7 +586,7 @@ public async Task GenerateExportfilesWithPregapAndPostgapTestAsync() } [TestMethod()] - public async Task GenerateExportfilesWithSplitPointsTestAsync() + public void GenerateExportfilesWithSplitPointsTest() { var testHelper = new TestHelper(); //Prepare cuesheet @@ -641,9 +641,9 @@ public async Task GenerateExportfilesWithSplitPointsTestAsync() SchemeTracks = "%Track.Position%;%Track.Artist%;%Track.Title%;%Track.Begin%;%Track.End%;%Track.Length%", SchemeFooter = "Exported %Cuesheet.Title% from %Cuesheet.Artist% using AudioCuesheetEditor" }; - var generator = new ExportfileGenerator(ExportType.Exportprofile, cuesheet, exportProfile, audioConverterService: testHelper.AudioConverterService); + var generator = new ExportfileGenerator(ExportType.Exportprofile, cuesheet, exportProfile); Assert.AreEqual(ValidationStatus.Success, generator.Validate().Status); - var generatedFiles = await generator.GenerateExportfilesAsync(); + var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(5, generatedFiles.Count); //Check split according to split points diff --git a/AudioCuesheetEditorTests/Utility/AudioConverterServiceUnitTest.cs b/AudioCuesheetEditorTests/Utility/AudioConverterServiceUnitTest.cs deleted file mode 100644 index 4176f28f..00000000 --- a/AudioCuesheetEditorTests/Utility/AudioConverterServiceUnitTest.cs +++ /dev/null @@ -1,33 +0,0 @@ -//This file is part of AudioCuesheetEditor. - -//AudioCuesheetEditor is free software: you can redistribute it and/or modify -//it under the terms of the GNU General Public License as published by -//the Free Software Foundation, either version 3 of the License, or -//(at your option) any later version. - -//AudioCuesheetEditor is distributed in the hope that it will be useful, -//but WITHOUT ANY WARRANTY; without even the implied warranty of -//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -//GNU General Public License for more details. - -//You should have received a copy of the GNU General Public License -//along with Foobar. If not, see -//. -using AudioCuesheetEditor.Model.IO.Audio; -using System; -using System.Threading.Tasks; - -namespace AudioCuesheetEditorTests.Utility -{ - internal class AudioConverterServiceUnitTest : IAudioConverterService - { - public event EventHandler? ProgressChanged; - - public Task SplitAudiofileAsync(Audiofile audiofile, TimeSpan from, TimeSpan? to = null) - { - ProgressChanged?.Invoke(this, 100); - // This implementation does nothing with audio processing, so we only return some fake data - return Task.FromResult(null); - } - } -} diff --git a/AudioCuesheetEditorTests/Utility/TestHelper.cs b/AudioCuesheetEditorTests/Utility/TestHelper.cs index ed78cda4..e5776f9c 100644 --- a/AudioCuesheetEditorTests/Utility/TestHelper.cs +++ b/AudioCuesheetEditorTests/Utility/TestHelper.cs @@ -31,11 +31,9 @@ public TestHelper() { LinkTracksWithPreviousOne = false }; - AudioConverterService = new AudioConverterServiceUnitTest(); } public ApplicationOptions ApplicationOptions { get; private set; } - public IAudioConverterService AudioConverterService { get; private set; } public static ILogger CreateLogger() { var serviceProvider = new ServiceCollection()