public void RemoveTrackTest() { var testHelper = new TestHelper(); testHelper.ApplicationOptions.LinkTracksWithPreviousOne = true; var cuesheet = new Cuesheet(); var track1 = new Track() { Artist = "1", Title = "1" }; var track2 = new Track() { Artist = "2", Title = "2" }; var track3 = new Track() { Artist = "3", Title = "3" }; var track4 = new Track() { Artist = "4", Title = "4" }; var track5 = new Track() { Artist = "5", Title = "5" }; cuesheet.AddTrack(track1, testHelper.ApplicationOptions); cuesheet.AddTrack(track2, testHelper.ApplicationOptions); cuesheet.AddTrack(track3, testHelper.ApplicationOptions); cuesheet.AddTrack(track4, testHelper.ApplicationOptions); cuesheet.AddTrack(track5, testHelper.ApplicationOptions); track1.End = new TimeSpan(0, 5, 0); track2.End = new TimeSpan(0, 10, 0); track3.End = new TimeSpan(0, 15, 0); track4.End = new TimeSpan(0, 20, 0); track5.End = new TimeSpan(0, 25, 0); Assert.AreEqual(5, cuesheet.Tracks.Count); cuesheet.RemoveTrack(track2); Assert.AreEqual((uint)2, track3.Position.Value); Assert.AreEqual((uint)3, track4.Position.Value); Assert.AreEqual((uint)4, track5.Position.Value); testHelper = new TestHelper(); testHelper.ApplicationOptions.LinkTracksWithPreviousOne = true; cuesheet = new Cuesheet(); track1 = new Track { Artist = "Track 1", Title = "Track 1" }; cuesheet.AddTrack(track1, testHelper.ApplicationOptions); track2 = new Track { Title = "Track 2", Artist = "Track 2", Begin = new TimeSpan(0, 5, 0) }; cuesheet.AddTrack(track2, testHelper.ApplicationOptions); track3 = new Track { Artist = "Track 3", Title = "Track 3", Begin = new TimeSpan(0, 10, 0) }; cuesheet.AddTrack(track3, testHelper.ApplicationOptions); track4 = new Track { Artist = "Track 4", Title = "Track 4", Begin = new TimeSpan(0, 15, 0) }; cuesheet.AddTrack(track4, testHelper.ApplicationOptions); track5 = new Track { Artist = "Track 5", Title = "Track 5", Begin = new TimeSpan(0, 20, 0) }; cuesheet.AddTrack(track5, testHelper.ApplicationOptions); var list = new List <Track>() { track2, track4 }; cuesheet.RemoveTracks(list.AsReadOnly()); Assert.AreEqual(3, cuesheet.Tracks.Count); Assert.AreEqual(new TimeSpan(0, 5, 0), track3.Begin); Assert.AreEqual(new TimeSpan(0, 15, 0), track5.Begin); Assert.AreEqual((uint)1, track1.Position); Assert.AreEqual((uint)2, track3.Position); Assert.AreEqual((uint)3, track5.Position); }
public void MoveAndDeleteTrackTest() { var testHelper = new TestHelper(); var cuesheet = new Cuesheet(); var track1 = new Track { Artist = "Track 1", Title = "Track 1" }; cuesheet.AddTrack(track1, testHelper.ApplicationOptions); var track2 = new Track { Title = "Track 2", Artist = "Track 2", Begin = new TimeSpan(0, 5, 0) }; cuesheet.AddTrack(track2, testHelper.ApplicationOptions); var track3 = new Track { Artist = "Track 3", Title = "Track 3", Begin = new TimeSpan(0, 10, 0) }; cuesheet.AddTrack(track3, testHelper.ApplicationOptions); var track4 = new Track { Artist = "Track 4", Title = "Track 4", Begin = new TimeSpan(0, 15, 0) }; cuesheet.AddTrack(track4, testHelper.ApplicationOptions); var track5 = new Track { Artist = "Track 5", Title = "Track 5", Begin = new TimeSpan(0, 20, 0) }; cuesheet.AddTrack(track5, testHelper.ApplicationOptions); cuesheet.RemoveTrack(track2); cuesheet.RemoveTrack(track4); Assert.AreEqual(3, cuesheet.Tracks.Count); track1.IsLinkedToPreviousTrack = true; track3.IsLinkedToPreviousTrack = true; track5.IsLinkedToPreviousTrack = true; var track1End = track1.End; testHelper.ApplicationOptions.LinkTracksWithPreviousOne = true; cuesheet.MoveTrack(track3, MoveDirection.Up); Assert.AreEqual((uint)1, track3.Position); Assert.AreEqual(track3, cuesheet.Tracks.ElementAt(0)); Assert.AreEqual(track1, cuesheet.GetPreviousLinkedTrack(track5)); Assert.AreEqual(TimeSpan.Zero, track3.Begin.Value); Assert.AreEqual(track1End, track1.Begin); cuesheet.MoveTrack(track5, MoveDirection.Up); Assert.AreEqual((uint)2, track5.Position); Assert.AreEqual(track5, cuesheet.Tracks.ElementAt(1)); Assert.AreEqual(track5, cuesheet.GetPreviousLinkedTrack(track1)); Assert.IsNull(cuesheet.Tracks.Last().End); //Reset for move down cuesheet.RemoveTracks(cuesheet.Tracks); track1 = new Track { Artist = "Track 1", Title = "Track 1" }; cuesheet.AddTrack(track1, testHelper.ApplicationOptions); track2 = new Track { Title = "Track 2", Artist = "Track 2", Begin = new TimeSpan(0, 5, 0) }; cuesheet.AddTrack(track2, testHelper.ApplicationOptions); track3 = new Track { Artist = "Track 3", Title = "Track 3", Begin = new TimeSpan(0, 10, 0) }; cuesheet.AddTrack(track3, testHelper.ApplicationOptions); track4 = new Track { Artist = "Track 4", Title = "Track 4", Begin = new TimeSpan(0, 15, 0) }; cuesheet.AddTrack(track4, testHelper.ApplicationOptions); track5 = new Track { Artist = "Track 5", Title = "Track 5", Begin = new TimeSpan(0, 20, 0) }; cuesheet.AddTrack(track5, testHelper.ApplicationOptions); cuesheet.RemoveTrack(track2); cuesheet.RemoveTrack(track4); Assert.AreEqual(3, cuesheet.Tracks.Count); testHelper.ApplicationOptions.LinkTracksWithPreviousOne = true; track3.IsLinkedToPreviousTrack = true; track5.IsLinkedToPreviousTrack = true; track1End = track1.End; cuesheet.MoveTrack(track1, MoveDirection.Down); Assert.AreEqual(track1, cuesheet.Tracks.ElementAt(1)); Assert.AreEqual(track3, cuesheet.GetPreviousLinkedTrack(track1)); Assert.AreEqual((uint)2, track1.Position.Value); Assert.AreEqual((uint)3, track5.Position.Value); Assert.AreEqual(track1, cuesheet.GetPreviousLinkedTrack(track5)); Assert.AreEqual(track1End, track3.End); }