From 059028836e1b67dabe181a01ad519034cc4b4263 Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Mon, 15 Apr 2024 08:45:24 +0200 Subject: [PATCH] Fixed renamed entities --- .../Model/IO/Export/ExportfileGenerator.cs | 21 +++-- .../Pages/EditSplitpoints.razor | 29 +++--- AudioCuesheetEditor/Shared/TracksTable.razor | 23 ++--- .../Model/AudioCuesheet/CuesheetTests.cs | 6 +- ...tPointTests.cs => CuesheetSectionTests.cs} | 18 ++-- .../IO/Export/ExportfileGeneratorTests.cs | 92 +++++++++---------- .../Model/IO/ProjectfileTests.cs | 18 ++-- 7 files changed, 105 insertions(+), 102 deletions(-) rename AudioCuesheetEditorTests/Model/IO/Export/{SplitPointTests.cs => CuesheetSectionTests.cs} (66%) diff --git a/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs b/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs index 1665e78b..36ee3d6a 100644 --- a/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs +++ b/AudioCuesheetEditor/Model/IO/Export/ExportfileGenerator.cs @@ -42,15 +42,16 @@ public IReadOnlyCollection GenerateExportfiles() List exportfiles = []; if (Validate().Status != ValidationStatus.Error) { - if (Cuesheet.SplitPoints.Count != 0) + if (Cuesheet.Sections.Count != 0) { + //TODO: Generate only splitpoint content (starting from begin to end) TimeSpan? previousSplitPointMoment = null; var begin = Cuesheet.Tracks.Min(x => x.Begin); var counter = 1; String? content = null; String filename = String.Empty; String? audioFileName = null; - foreach (var splitPoint in Cuesheet.SplitPoints.OrderBy(x => x.Moment)) + foreach (var splitPoint in Cuesheet.Sections.OrderBy(x => x.Begin)) { audioFileName = splitPoint.AudiofileName; if (splitPoint.Validate().Status == ValidationStatus.Success) @@ -75,9 +76,9 @@ public IReadOnlyCollection GenerateExportfiles() { begin = previousSplitPointMoment; } - exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = begin, End = splitPoint.Moment }); + exportfiles.Add(new Exportfile() { Name = filename, Content = Encoding.UTF8.GetBytes(content), Begin = begin, End = splitPoint.Begin }); } - previousSplitPointMoment = splitPoint.Moment; + previousSplitPointMoment = splitPoint.Begin; counter++; } } @@ -146,7 +147,7 @@ public IReadOnlyCollection GenerateExportfiles() return exportfiles; } - private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null) + private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, CuesheetSection? splitPoint = null) { var builder = new StringBuilder(); if (Cuesheet.Cataloguenumber != null && string.IsNullOrEmpty(Cuesheet.Cataloguenumber.Value) == false && Cuesheet.Cataloguenumber.Validate().Status != ValidationStatus.Error) @@ -163,7 +164,7 @@ private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, Split IEnumerable tracks = Cuesheet.Tracks.OrderBy(x => x.Position); if (from != null && splitPoint != null) { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment && x.End >= from).OrderBy(x => x.Position); + tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Begin && x.End >= from).OrderBy(x => x.Position); } else { @@ -173,7 +174,7 @@ private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, Split } if (splitPoint != null) { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment).OrderBy(x => x.Position); + tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Begin).OrderBy(x => x.Position); } } if (tracks.Any()) @@ -222,7 +223,7 @@ private string WriteCuesheet(String? audiofileName, TimeSpan? from = null, Split return builder.ToString(); } - private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPoint? splitPoint = null) + private String WriteExport(String? audiofileName, TimeSpan? from = null, CuesheetSection? splitPoint = null) { var builder = new StringBuilder(); if (Exportprofile != null) @@ -240,7 +241,7 @@ private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPo IEnumerable tracks = Cuesheet.Tracks.OrderBy(x => x.Position); if (from != null && splitPoint != null) { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment && x.End >= from).OrderBy(x => x.Position); + tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Begin && x.End >= from).OrderBy(x => x.Position); } else { @@ -250,7 +251,7 @@ private String WriteExport(String? audiofileName, TimeSpan? from = null, SplitPo } if (splitPoint != null) { - tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Moment).OrderBy(x => x.Position); + tracks = Cuesheet.Tracks.Where(x => x.Begin <= splitPoint.Begin).OrderBy(x => x.Position); } } if (tracks.Any()) diff --git a/AudioCuesheetEditor/Pages/EditSplitpoints.razor b/AudioCuesheetEditor/Pages/EditSplitpoints.razor index c551484b..5f43ef00 100644 --- a/AudioCuesheetEditor/Pages/EditSplitpoints.razor +++ b/AudioCuesheetEditor/Pages/EditSplitpoints.razor @@ -25,7 +25,7 @@ along with Foobar. If not, see @inject TraceChangeManager _traceChangeManager @inject IJSRuntime _jsRuntime - +@* @if (Cuesheet != null) { @if (_sessionStateContainer.CurrentViewMode == ViewMode.ViewModeFull) @@ -56,7 +56,7 @@ along with Foobar. If not, see - @foreach (var splitPoint in Cuesheet.SplitPoints) + @foreach (var splitPoint in Cuesheet.Sections) { @@ -75,8 +75,8 @@ along with Foobar. If not, see - - + + @@ -84,7 +84,7 @@ along with Foobar. If not, see - + @@ -93,7 +93,7 @@ along with Foobar. If not, see - + @@ -102,7 +102,7 @@ along with Foobar. If not, see - + @if (String.IsNullOrEmpty(splitPoint.AudiofileName)) { x.MimeType))" Changed="(args) => OnSplitpointAudiofileChanged(args, splitPoint)" AutoReset="false"> @@ -133,15 +133,16 @@ along with Foobar. If not, see } - + *@ @code { + //TODO: Rename component! Validations? validations; ModalDialog? modalDialog; Validation? audiofileValidation; - Dictionary fileEditAudiofileIds = new(); + Dictionary fileEditAudiofileIds = new(); public Cuesheet? Cuesheet { @@ -204,18 +205,18 @@ along with Foobar. If not, see { if (Cuesheet != null) { - var splitPoint = Cuesheet.AddSplitPoint(); + var splitPoint = Cuesheet.AddSection(); _traceChangeManager.TraceChanges(splitPoint); fileEditAudiofileIds.Add(splitPoint, Guid.NewGuid()); } return Task.CompletedTask; } - Task DeleteSplitPointClicked(SplitPoint splitPoint) + Task DeleteSplitPointClicked(CuesheetSection splitPoint) { if (Cuesheet != null) { - Cuesheet.RemoveSplitPoint(splitPoint); + Cuesheet.RemoveSection(splitPoint); } return Task.CompletedTask; } @@ -265,7 +266,7 @@ along with Foobar. If not, see StateHasChanged(); } - async Task OnSplitpointAudiofileChangedCliccked(SplitPoint splitPoint) + async Task OnSplitpointAudiofileChangedCliccked(CuesheetSection splitPoint) { splitPoint.AudiofileName = null; StateHasChanged(); @@ -273,7 +274,7 @@ along with Foobar. If not, see await _jsRuntime.InvokeVoidAsync("triggerClick", fileEditAudiofileIds[splitPoint]); } - async Task OnSplitpointAudiofileChanged(FileChangedEventArgs e, SplitPoint splitPoint) + async Task OnSplitpointAudiofileChanged(FileChangedEventArgs e, CuesheetSection splitPoint) { if (e.Files.FirstOrDefault() != null) { diff --git a/AudioCuesheetEditor/Shared/TracksTable.razor b/AudioCuesheetEditor/Shared/TracksTable.razor index 8c97bc92..6252e512 100644 --- a/AudioCuesheetEditor/Shared/TracksTable.razor +++ b/AudioCuesheetEditor/Shared/TracksTable.razor @@ -329,7 +329,7 @@ along with Foobar. If not, see case ViewMode.ViewModeImport:
- @if (Cuesheet?.GetSplitPointAtTrack(track) != null) + @if (Cuesheet?.GetSectionAtTrack(track) != null) { @@ -768,8 +768,8 @@ along with Foobar. If not, see { if (Cuesheet != null) { - Cuesheet.SplitPointAdded += Cuesheet_SplitPointAdded; - Cuesheet.SplitPointRemoved += Cuesheet_SplitPointRemoved; + Cuesheet.SectionAdded += Cuesheet_SectionAdded; + Cuesheet.SectionRemoved += Cuesheet_SectionRemoved; } } @@ -777,26 +777,27 @@ along with Foobar. If not, see { if (Cuesheet != null) { - Cuesheet.SplitPointAdded -= Cuesheet_SplitPointAdded; - Cuesheet.SplitPointRemoved -= Cuesheet_SplitPointRemoved; + Cuesheet.SectionAdded -= Cuesheet_SectionAdded; + Cuesheet.SectionRemoved -= Cuesheet_SectionRemoved; } } - void Cuesheet_SplitPointAdded(object? sender, SplitPointAddRemoveEventArgs args) + void Cuesheet_SectionAdded(object? sender, CuesheetSectionAddRemoveEventArgs args) { - args.SplitPoint.ValidateablePropertyChanged += SplitPoint_ValidateablePropertyChanged; + args.Section.ValidateablePropertyChanged += Section_ValidateablePropertyChanged; } - void Cuesheet_SplitPointRemoved(object? sender, SplitPointAddRemoveEventArgs args) + void Cuesheet_SectionRemoved(object? sender, CuesheetSectionAddRemoveEventArgs args) { - args.SplitPoint.ValidateablePropertyChanged -= SplitPoint_ValidateablePropertyChanged; + args.Section.ValidateablePropertyChanged -= Section_ValidateablePropertyChanged; } - void SplitPoint_ValidateablePropertyChanged(object? sender, string property) + void Section_ValidateablePropertyChanged(object? sender, string property) { switch (property) { - case nameof(SplitPoint.Moment): + case nameof(CuesheetSection.Begin): + case nameof(CuesheetSection.End): StateHasChanged(); break; } diff --git a/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs b/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs index 8eb7f310..ee82dc26 100644 --- a/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs +++ b/AudioCuesheetEditorTests/Model/AudioCuesheet/CuesheetTests.cs @@ -611,12 +611,12 @@ public void ImportProjectfileTest() var fileContent = Encoding.UTF8.GetBytes("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Artist 1\",\"Title\":\"Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:01:01\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":2,\"Artist\":\"Artist 2\",\"Title\":\"Title 2\",\"Begin\":\"00:01:01\",\"End\":\"00:03:03\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":3,\"Artist\":\"Artist 3\",\"Title\":\"Title 3\",\"Begin\":\"00:03:03\",\"End\":\"00:06:06\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":4,\"Artist\":\"Artist 4\",\"Title\":\"Title 4\",\"Begin\":\"00:06:06\",\"End\":\"00:10:10\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":5,\"Artist\":\"Artist 5\",\"Title\":\"Title 5\",\"Begin\":\"00:10:10\",\"End\":\"00:15:15\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":6,\"Artist\":\"Artist 6\",\"Title\":\"Title 6\",\"Begin\":\"00:15:15\",\"End\":\"00:21:21\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":7,\"Artist\":\"Artist 7\",\"Title\":\"Title 7\",\"Begin\":\"00:21:21\",\"End\":\"00:28:28\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":8,\"Artist\":\"Artist 8\",\"Title\":\"Title 8\",\"Begin\":\"00:28:28\",\"End\":\"00:36:36\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":9,\"Artist\":\"Artist 9\",\"Title\":\"Title 9\",\"Begin\":\"00:36:36\",\"End\":\"00:45:45\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":10,\"Artist\":\"Artist 10\",\"Title\":\"Title 10\",\"Begin\":\"00:45:45\",\"End\":\"00:55:55\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Audiofile\":{\"Name\":\"AudioFile.mp3\"},\"CDTextfile\":{\"Name\":\"CDTextfile.cdt\"},\"Cataloguenumber\":{\"Value\":\"A123\"},\"SplitPoints\":[{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"00:30:00\"},{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"01:00:00\"}]}"); var projectFileCuesheet = Projectfile.ImportFile(fileContent); Assert.IsNotNull(projectFileCuesheet); - Assert.AreEqual(2, projectFileCuesheet.SplitPoints.Count); + Assert.AreEqual(2, projectFileCuesheet.Sections.Count); var cuesheet = new Cuesheet(); var testHelper = new TestHelper(); cuesheet.Import(projectFileCuesheet, testHelper.ApplicationOptions); - Assert.AreEqual(2, cuesheet.SplitPoints.Count); - Assert.IsTrue(cuesheet.SplitPoints.All(x => x.Cuesheet == cuesheet)); + Assert.AreEqual(2, cuesheet.Sections.Count); + Assert.IsTrue(cuesheet.Sections.All(x => x.Cuesheet == cuesheet)); } } } \ No newline at end of file diff --git a/AudioCuesheetEditorTests/Model/IO/Export/SplitPointTests.cs b/AudioCuesheetEditorTests/Model/IO/Export/CuesheetSectionTests.cs similarity index 66% rename from AudioCuesheetEditorTests/Model/IO/Export/SplitPointTests.cs rename to AudioCuesheetEditorTests/Model/IO/Export/CuesheetSectionTests.cs index d4dc78e2..f44a40e0 100644 --- a/AudioCuesheetEditorTests/Model/IO/Export/SplitPointTests.cs +++ b/AudioCuesheetEditorTests/Model/IO/Export/CuesheetSectionTests.cs @@ -11,25 +11,25 @@ namespace AudioCuesheetEditor.Model.IO.Export.Tests { [TestClass()] - public class SplitPointTests + public class CuesheetSectionTests { [TestMethod()] public void ValidationTest() { var cuesheet = new Cuesheet(); - var splitPoint = new SplitPoint(cuesheet); - Assert.IsNull(splitPoint.Moment); - var validationResult = splitPoint.Validate(x => x.Moment); + var section = new CuesheetSection(cuesheet); + Assert.IsNull(section.Begin); + var validationResult = section.Validate(x => x.Begin); Assert.AreEqual(ValidationStatus.Error, validationResult.Status); - splitPoint.Moment = new TimeSpan(0, 30, 0); - validationResult = splitPoint.Validate(x => x.Moment); + section.Begin = new TimeSpan(0, 30, 0); + validationResult = section.Validate(x => x.Begin); Assert.AreEqual(ValidationStatus.Success, validationResult.Status); cuesheet.AddTrack(new Track() { Position = 1}); cuesheet.AddTrack(new Track() { Position = 2, Begin = new TimeSpan(0, 8, 43), End = new TimeSpan(0, 15, 43) }); - validationResult = splitPoint.Validate(x => x.Moment); + validationResult = section.Validate(x => x.Begin); Assert.AreEqual(ValidationStatus.Error, validationResult.Status); - splitPoint.Moment = new TimeSpan(0, 15, 43); - validationResult = splitPoint.Validate(x => x.Moment); + section.Begin = new TimeSpan(0, 15, 43); + validationResult = section.Validate(x => x.Begin); Assert.AreEqual(ValidationStatus.Success, validationResult.Status); } } diff --git a/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs b/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs index a06551f6..433c998d 100644 --- a/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs +++ b/AudioCuesheetEditorTests/Model/IO/Export/ExportfileGeneratorTests.cs @@ -280,7 +280,7 @@ public void GenerateCuesheetFilesWithIncorrectTrackPositionsTest() } [TestMethod()] - public void GenerateCuesheetFilesWithSplitPointsTest() + public void GenerateCuesheetFilesWithSectionsTest() { var testHelper = new TestHelper(); Cuesheet cuesheet = new() @@ -302,21 +302,21 @@ public void GenerateCuesheetFilesWithSplitPointsTest() track.End = begin; cuesheet.AddTrack(track, testHelper.ApplicationOptions); } - var splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(2, 0, 0); - splitPoint.Title = "Last part"; - splitPoint.AudiofileName = "Last part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(0, 30, 0); - splitPoint.AudiofileName = "First part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(1, 0, 0); - splitPoint.Artist = "Demo Artist Part2"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Artist = "Artist 3"; - splitPoint.Title = "Title 3"; - splitPoint.AudiofileName = "Part 3.mp3"; - splitPoint.Moment = new TimeSpan(1, 30, 0); + var section = cuesheet.AddSection(); + section.Begin = new TimeSpan(2, 0, 0); + section.Title = "Last part"; + section.AudiofileName = "Last part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 30, 0); + section.AudiofileName = "First part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(1, 0, 0); + section.Artist = "Demo Artist Part2"; + section = cuesheet.AddSection(); + section.Artist = "Artist 3"; + section.Title = "Title 3"; + section.AudiofileName = "Part 3.mp3"; + section.Begin = new TimeSpan(1, 30, 0); testHelper.ApplicationOptions.CuesheetFilename = "Unit test.cue"; var generator = new ExportfileGenerator(ExportType.Cuesheet, cuesheet, applicationOptions: testHelper.ApplicationOptions); Assert.AreEqual(ValidationStatus.Success, generator.Validate().Status); @@ -324,7 +324,7 @@ public void GenerateCuesheetFilesWithSplitPointsTest() Assert.AreEqual(5, generatedFiles.Count); var position = 1; var counter = 1; - //Check split according to split points + //Check split according to sections Assert.AreEqual(cuesheet.Tracks.Min(x => x.Begin), generatedFiles.First().Begin); Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.First().End); Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.ElementAt(1).Begin); @@ -346,13 +346,13 @@ public void GenerateCuesheetFilesWithSplitPointsTest() var fileContent = File.ReadAllLines(fileName); File.Delete(fileName); int positionDifference = 1 - position; - // Check cuesheet header for splitpoint artist and title - var splitPointForThisFile = cuesheet.SplitPoints.FirstOrDefault(x => x.Moment == generatedFile.End); - if (splitPointForThisFile != null) + // Check cuesheet header for artist and title + var sectionForThisFile = cuesheet.Sections.FirstOrDefault(x => x.Begin == generatedFile.End); + if (sectionForThisFile != null) { - Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, splitPointForThisFile.Title), fileContent.First()); - Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, splitPointForThisFile.Artist), fileContent[1]); - Assert.AreEqual(String.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, splitPointForThisFile.AudiofileName, cuesheet.Audiofile?.AudioFileType), fileContent[2]); + Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetTitle, sectionForThisFile.Title), fileContent.First()); + Assert.AreEqual(String.Format("{0} \"{1}\"", CuesheetConstants.CuesheetArtist, sectionForThisFile.Artist), fileContent[1]); + Assert.AreEqual(String.Format("{0} \"{1}\" {2}", CuesheetConstants.CuesheetFileName, sectionForThisFile.AudiofileName, cuesheet.Audiofile?.AudioFileType), fileContent[2]); } else { @@ -592,7 +592,7 @@ public void GenerateExportfilesWithPregapAndPostgapTest() } [TestMethod()] - public void GenerateExportfilesWithSplitPointsTest() + public void GenerateExportfilesWithSectionsTest() { var testHelper = new TestHelper(); //Prepare cuesheet @@ -627,21 +627,21 @@ public void GenerateExportfilesWithSplitPointsTest() cuesheet.Cataloguenumber.Value = "0123456789123"; cuesheet.CDTextfile = new CDTextfile("Testfile.cdt"); - var splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(2, 0, 0); - splitPoint.Title = "Last part"; - splitPoint.AudiofileName = "Last part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(0, 30, 0); - splitPoint.AudiofileName = "First part.mp3"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(1, 0, 0); - splitPoint.Artist = "Demo Artist Part2"; - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Artist = "Artist 3"; - splitPoint.Title = "Title 3"; - splitPoint.AudiofileName = "Part 3.mp3"; - splitPoint.Moment = new TimeSpan(1, 30, 0); + var section = cuesheet.AddSection(); + section.Begin = new TimeSpan(2, 0, 0); + section.Title = "Last part"; + section.AudiofileName = "Last part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 30, 0); + section.AudiofileName = "First part.mp3"; + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(1, 0, 0); + section.Artist = "Demo Artist Part2"; + section = cuesheet.AddSection(); + section.Artist = "Artist 3"; + section.Title = "Title 3"; + section.AudiofileName = "Part 3.mp3"; + section.Begin = new TimeSpan(1, 30, 0); //Test export var exportProfile = new Exportprofile { @@ -654,7 +654,7 @@ public void GenerateExportfilesWithSplitPointsTest() var generatedFiles = generator.GenerateExportfiles(); Assert.AreEqual(5, generatedFiles.Count); - //Check split according to split points + //Check split according to sections Assert.AreEqual(cuesheet.Tracks.Min(x => x.Begin), generatedFiles.First().Begin); Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.First().End); Assert.AreEqual(new TimeSpan(0, 30, 0), generatedFiles.ElementAt(1).Begin); @@ -678,11 +678,11 @@ public void GenerateExportfilesWithSplitPointsTest() var fileContent = File.ReadAllLines(fileName); File.Delete(fileName); int positionDifference = 1 - position; - //Check cuesheet header for splitpoint artist and title - var splitPointForThisFile = cuesheet.SplitPoints.FirstOrDefault(x => x.Moment == generatedFile.End); - if (splitPointForThisFile != null) + //Check cuesheet header for artist and title + var sectionForThisFile = cuesheet.Sections.FirstOrDefault(x => x.Begin == generatedFile.End); + if (sectionForThisFile != null) { - Assert.AreEqual(String.Format("{0};{1};{2};0123456789123;Testfile.cdt", splitPointForThisFile.Artist, splitPointForThisFile.Title, splitPointForThisFile.AudiofileName), fileContent[0]); + Assert.AreEqual(String.Format("{0};{1};{2};0123456789123;Testfile.cdt", sectionForThisFile.Artist, sectionForThisFile.Title, sectionForThisFile.AudiofileName), fileContent[0]); } else { @@ -710,9 +710,9 @@ public void GenerateExportfilesWithSplitPointsTest() } Assert.AreEqual(String.Format("{0};{1};{2};{3};{4};{5}", track.Position + positionDifference, track.Artist, track.Title, trackBegin, trackEnd, trackEnd - trackBegin), fileContent[i]); } - if (splitPointForThisFile != null) + if (sectionForThisFile != null) { - Assert.AreEqual(String.Format("Exported {0} from {1} using AudioCuesheetEditor", splitPointForThisFile.Title, splitPointForThisFile.Artist), fileContent.Last()); + Assert.AreEqual(String.Format("Exported {0} from {1} using AudioCuesheetEditor", sectionForThisFile.Title, sectionForThisFile.Artist), fileContent.Last()); } else { diff --git a/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs b/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs index 022cec94..433ff166 100644 --- a/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs +++ b/AudioCuesheetEditorTests/Model/IO/ProjectfileTests.cs @@ -70,7 +70,7 @@ public void GenerateFileTest() } [TestMethod()] - public void GenerateFileWithSplitPointsTest() + public void GenerateFileWithSectionsTest() { var cuesheet = new Cuesheet { @@ -100,10 +100,10 @@ public void GenerateFileWithSplitPointsTest() track.End = begin; cuesheet.AddTrack(track, new Options.ApplicationOptions() { LinkTracksWithPreviousOne = true }); } - var splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(0, 30, 0); - splitPoint = cuesheet.AddSplitPoint(); - splitPoint.Moment = new TimeSpan(1, 0, 0); + var section = cuesheet.AddSection(); + section.Begin = new TimeSpan(0, 30, 0); + section = cuesheet.AddSection(); + section.Begin = new TimeSpan(1, 0, 0); var projectFile = new Projectfile(cuesheet); var generatedFile = projectFile.GenerateFile(); Assert.IsNotNull(generatedFile); @@ -139,7 +139,7 @@ public void ImportFileTest() } [TestMethod()] - public void ImportFileWithSplitPointsTest() + public void ImportFileWithSectionsTest() { var fileContent = Encoding.UTF8.GetBytes("{\"Tracks\":[{\"Position\":1,\"Artist\":\"Artist 1\",\"Title\":\"Title 1\",\"Begin\":\"00:00:00\",\"End\":\"00:01:01\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":2,\"Artist\":\"Artist 2\",\"Title\":\"Title 2\",\"Begin\":\"00:01:01\",\"End\":\"00:03:03\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":3,\"Artist\":\"Artist 3\",\"Title\":\"Title 3\",\"Begin\":\"00:03:03\",\"End\":\"00:06:06\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":4,\"Artist\":\"Artist 4\",\"Title\":\"Title 4\",\"Begin\":\"00:06:06\",\"End\":\"00:10:10\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":5,\"Artist\":\"Artist 5\",\"Title\":\"Title 5\",\"Begin\":\"00:10:10\",\"End\":\"00:15:15\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":6,\"Artist\":\"Artist 6\",\"Title\":\"Title 6\",\"Begin\":\"00:15:15\",\"End\":\"00:21:21\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":7,\"Artist\":\"Artist 7\",\"Title\":\"Title 7\",\"Begin\":\"00:21:21\",\"End\":\"00:28:28\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":8,\"Artist\":\"Artist 8\",\"Title\":\"Title 8\",\"Begin\":\"00:28:28\",\"End\":\"00:36:36\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":9,\"Artist\":\"Artist 9\",\"Title\":\"Title 9\",\"Begin\":\"00:36:36\",\"End\":\"00:45:45\",\"Flags\":[\"4CH\"],\"IsLinkedToPreviousTrack\":true},{\"Position\":10,\"Artist\":\"Artist 10\",\"Title\":\"Title 10\",\"Begin\":\"00:45:45\",\"End\":\"00:55:55\",\"Flags\":[\"4CH\",\"DCP\"],\"IsLinkedToPreviousTrack\":true}],\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Audiofile\":{\"Name\":\"AudioFile.mp3\"},\"CDTextfile\":{\"Name\":\"CDTextfile.cdt\"},\"Cataloguenumber\":{\"Value\":\"A123\"},\"SplitPoints\":[{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"00:30:00\"},{\"Artist\":\"CuesheetArtist\",\"Title\":\"CuesheetTitle\",\"Moment\":\"01:00:00\"}]}"); var cuesheet = Projectfile.ImportFile(fileContent); @@ -159,9 +159,9 @@ public void ImportFileWithSplitPointsTest() Assert.IsTrue(Object.ReferenceEquals(cuesheet.Tracks.First(), cuesheet.GetPreviousLinkedTrack(cuesheet.Tracks.ElementAt(1)))); Assert.AreEqual(cuesheet.Tracks.First(), cuesheet.GetPreviousLinkedTrack(cuesheet.Tracks.ElementAt(1))); Assert.AreEqual((uint)10, cuesheet.Tracks.Last().Position); - Assert.AreEqual(2, cuesheet.SplitPoints.Count); - Assert.AreEqual(new TimeSpan(0, 30, 0), cuesheet.SplitPoints.First().Moment); - Assert.AreEqual(new TimeSpan(1, 0, 0), cuesheet.SplitPoints.Last().Moment); + Assert.AreEqual(2, cuesheet.Sections.Count); + Assert.AreEqual(new TimeSpan(0, 30, 0), cuesheet.Sections.First().Begin); + Assert.AreEqual(new TimeSpan(1, 0, 0), cuesheet.Sections.Last().Begin); } } } \ No newline at end of file