From 53af612ec6c0a409c254f9748be2cfeb5cfdf672 Mon Sep 17 00:00:00 2001 From: NeoCoderMatrix86 <40752681+NeoCoderMatrix86@users.noreply.github.com> Date: Fri, 13 Dec 2024 11:20:34 +0100 Subject: [PATCH] Bugfix #397 - setting begin when setting link to previous track --- .../Model/AudioCuesheet/CuesheetTests.cs | 30 +++++++++++++++++++ .../Model/AudioCuesheet/Cuesheet.cs | 4 +++ 2 files changed, 34 insertions(+) diff --git a/AudioCuesheetEditor.Tests/Model/AudioCuesheet/CuesheetTests.cs b/AudioCuesheetEditor.Tests/Model/AudioCuesheet/CuesheetTests.cs index d524a6d7..dd8dbb9b 100644 --- a/AudioCuesheetEditor.Tests/Model/AudioCuesheet/CuesheetTests.cs +++ b/AudioCuesheetEditor.Tests/Model/AudioCuesheet/CuesheetTests.cs @@ -638,5 +638,35 @@ public void ValidateTest() cuesheet.Title = "Testtitle"; Assert.AreEqual(ValidationStatus.Success, cuesheet.Validate(x => x.Title).Status); } + + [TestMethod()] + public void IsLinkedToPreviousTrack_ChangedLastTrackBegin_SetsTrackProperties() + { + //Arrange + var applicationOptions = new ApplicationOptions() + { + LinkTracksWithPreviousOne = false + }; + var cuesheet = new Cuesheet(); + var track1 = new Track() + { + Artist = "Track1 Artist", + Title = "Track1 Title" + }; + var track2 = new Track() + { + Artist = "Track2 Artist", + Title = "Track2 Title", + End = new TimeSpan(0, 9, 12) + }; + cuesheet.AddTrack(track1, applicationOptions); + cuesheet.AddTrack(track2, applicationOptions); + track2.Begin = new TimeSpan(0, 4, 23); + //Act + track2.IsLinkedToPreviousTrack = true; + //Assert + Assert.AreEqual((uint)2, track2.Position); + Assert.AreEqual(track2.Begin, track1.End); + } } } \ No newline at end of file diff --git a/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs b/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs index b41356c4..0d70dca3 100644 --- a/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs +++ b/AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs @@ -607,6 +607,10 @@ private void Track_IsLinkedToPreviousTrackChanged(object? sender, EventArgs e) { trackRaisedEvent.Begin = previousTrack.End; } + if ((previousTrack.End.HasValue == false) && (trackRaisedEvent.Begin.HasValue)) + { + previousTrack.End = trackRaisedEvent.Begin; + } } } }