Ejemplo n.º 1
0
        public void PlayTestWithShadowsPlaybackStopped()
        {
            var helper = new PlayTestHelper();

            helper.Manager.PlaybackStopped += (sender, args) => {
                if (args.NextShadow == null)
                {
                    return;
                }
                args.Item       = args.NextShadow;
                args.NextShadow = null;
            };

            // queue with one item, add shadow
            helper.Enqueue(QueueItems[0]);
            helper.Manager.NextSongShadow = QueueItems[1];
            helper.Play(QueueItems[0], 0);

            // first song is playing, check that the shadow is preparing
            helper.CheckIsPreparing(QueueItems[1]);
            helper.InvokeSongEnd();

            // item gets filled in by event handler, is added to queue and plays now
            helper.Play(QueueItems[1], 1);
            helper.InvokeSongEnd();

            helper.AssertAtEndOfPlay();
            helper.CheckTasksCanceled(0);
        }
Ejemplo n.º 2
0
        public void PlayTestMultipleSongsWithFailures()
        {
            var helper = new PlayTestHelper();

            foreach (var item in QueueItems)
            {
                helper.Enqueue(item);
            }

            // Let a few songs fail
            for (var i = 0; i < Iterations; ++i)
            {
                var queueItem = QueueItems[i];

                if (ShouldFailSong(i))
                {
                    helper.FailLoad(queueItem);
                    continue;
                }

                helper.Play(queueItem, i);
                helper.InvokeSongEnd();
            }

            helper.AssertAtEndOfPlay();
            helper.CheckTasksCanceled(0);
        }
Ejemplo n.º 3
0
        public void PlayTestWithShadows()
        {
            var helper = new PlayTestHelper();

            // queue with one item, add shadow
            helper.Enqueue(QueueItems[0]);
            helper.Manager.NextSongShadow = QueueItems[1];
            helper.Play(QueueItems[0], 0);

            // first song is playing, check that the shadow is preparing
            helper.CheckIsPreparing(QueueItems[1]);
            helper.Enqueue(QueueItems[2]);

            // a new song is enqueued, check that it is preparing
            helper.CheckIsPreparing(QueueItems[2]);
            helper.CheckTasksCanceled(1);

            // next song index is valid
            helper.CheckNextSongIndex(1);

            helper.InvokeSongEnd();
            helper.Play(QueueItems[2], 1);

            // shadow is kept
            helper.CheckIsPreparing(QueueItems[1]);

            // next song index is still valid
            helper.CheckNextSongIndex(2);

            helper.InvokeSongEnd();
            helper.AssertAtEndOfQueue();

            // Add the shadow song when not playing and at end of queue
            helper.Enqueue(QueueItems[1]);
            helper.Play(QueueItems[1], 2);

            // shadow gets cleared after play
            Assert.AreSame(helper.Manager.NextSongShadow, null);
            helper.CheckIsPreparing(null);
            helper.CheckNextSongIndex(3);

            helper.InvokeSongEnd();

            helper.AssertAtEndOfPlay();
            helper.CheckTasksCanceled(1);
        }
Ejemplo n.º 4
0
        public void SimplePlayTest()
        {
            var helper = new PlayTestHelper();

            var queueItem = QueueItems[0];

            helper.Enqueue(queueItem);
            helper.CheckIsPreparing(queueItem);
            helper.Play(queueItem, 0);
            helper.InvokeSongEnd();

            helper.AssertAtEndOfPlay();
            helper.CheckTasksCanceled(0);
        }
Ejemplo n.º 5
0
        public void PlayTestMultipleSongsWithFailuresLoadBeforeSongEnd()
        {
            var helper = new PlayTestHelper();

            foreach (var item in QueueItems)
            {
                helper.Enqueue(item);
            }

            if (ShouldFailSong(0))
            {
                helper.FailLoad(QueueItems[0]);
            }

            // Let a few songs fail
            // current song is already prepared
            for (var i = 0; i < Iterations; ++i)
            {
                var queueItem = QueueItems[i];

                if (ShouldFailSong(i))
                {
                    continue;
                }

                helper.Play(queueItem, i);

                for (var j = i + 1; j < Iterations; ++j)
                {
                    if (ShouldFailSong(j))
                    {
                        helper.FailLoad(QueueItems[j]);
                    }
                    else
                    {
                        break;
                    }
                }

                helper.InvokeSongEnd();
            }

            helper.AssertAtEndOfPlay();
            helper.CheckTasksCanceled(0);
        }
Ejemplo n.º 6
0
        public void PlayTestMultipleSongs()
        {
            var helper = new PlayTestHelper();

            foreach (var item in QueueItems)
            {
                helper.Enqueue(item);
            }

            for (var i = 0; i < Iterations; ++i)
            {
                var queueItem = QueueItems[i];
                helper.Play(queueItem, i);
                helper.InvokeSongEnd();
            }

            helper.AssertAtEndOfPlay();
            helper.CheckTasksCanceled(0);
        }