Beispiel #1
0
        public void GetPlaylistsSucceedNotLoggedIn()
        {
            SpotifyPlayer          player            = CreateInitializedPlayer();
            Mock <ISpotifyWrapper> wrapper           = Mock.Get(player.Spotify);
            List <String>          expectedPlaylists = new List <string>
            {
                "Test Playlist",
                "Test Playlist 2",
                "Test Playlist 3",
            };

            wrapper.Setup(p => p.LogIn());
            wrapper.Setup(p => p.GetPlaylists()).Returns(expectedPlaylists);
            wrapper.Setup(p => p.LogOut());

            IEnumerable <String> playlists = player.GetPlaylists();

            wrapper.Verify(p => p.GetPlaylists(), Times.Exactly(1));
            wrapper.Verify(p => p.LogIn(), Times.Exactly(1));
            wrapper.Verify(p => p.LogOut(), Times.Exactly(1));
            Assert.AreEqual(expectedPlaylists.Count, playlists.Count());
            Assert.IsTrue(expectedPlaylists.Contains(playlists.ElementAt(0)));
            Assert.IsTrue(expectedPlaylists.Contains(playlists.ElementAt(1)));
            Assert.IsTrue(expectedPlaylists.Contains(playlists.ElementAt(2)));
            Assert.AreEqual(PlayerState.Stopped, player.State);
        }