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; + } } } }