Esempio n. 1
0
        public void MoveTrackTest()
        {
            var testHelper = new TestHelper();
            var cuesheet   = new Cuesheet();
            var track1     = new Track();

            cuesheet.AddTrack(track1, testHelper.ApplicationOptions);
            var track2 = new Track();

            cuesheet.AddTrack(track2, testHelper.ApplicationOptions);
            var track3 = new Track();

            cuesheet.AddTrack(track3, testHelper.ApplicationOptions);
            Assert.AreEqual(cuesheet.Tracks.Count, 3);
            Assert.IsTrue(track1.Position.Value == 1);
            cuesheet.MoveTrack(track1, MoveDirection.Up);
            Assert.IsTrue(track1.Position.Value == 1);
            Assert.IsTrue(track3.Position.Value == 3);
            cuesheet.MoveTrack(track3, MoveDirection.Down);
            Assert.IsTrue(track3.Position.Value == 3);
            Assert.IsTrue(track2.Position.Value == 2);
            cuesheet.MoveTrack(track2, MoveDirection.Up);
            Assert.AreEqual(track2, cuesheet.Tracks.ElementAt(0));
            Assert.AreEqual(track1, cuesheet.Tracks.ElementAt(1));
            cuesheet.MoveTrack(track2, MoveDirection.Down);
            cuesheet.MoveTrack(track2, MoveDirection.Down);
            Assert.AreEqual(track2, cuesheet.Tracks.ElementAt(2));
            Assert.AreEqual(track1, cuesheet.Tracks.ElementAt(0));
            Assert.AreEqual(track3, cuesheet.Tracks.ElementAt(1));
        }
Esempio n. 2
0
        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);
        }