Skip to content

Commit

Permalink
Merge pull request #403 from NeoCoderMatrix86/397-link-track-with-pre…
Browse files Browse the repository at this point in the history
…vious-one-doesnt-set-end-of-previous-track

Bugfix #397
  • Loading branch information
NeoCoderMatrix86 authored Dec 13, 2024
2 parents a0f7cbe + 53af612 commit f5333c6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
30 changes: 30 additions & 0 deletions AudioCuesheetEditor.Tests/Model/AudioCuesheet/CuesheetTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
4 changes: 4 additions & 0 deletions AudioCuesheetEditor/Model/AudioCuesheet/Cuesheet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
Expand Down

0 comments on commit f5333c6

Please sign in to comment.