public async Task SmokeTest() { var songs = Helpers.SetupSongs(2); var playlist = new NetworkPlaylist { Name = "A", Songs = songs, CurrentIndex = 0 }; var messenger = CreateDefaultPlaylistMessenger(); messenger.GetCurrentPlaylistAsync().Returns(playlist.ToTaskResult()); messenger.PlayPlaylistSongAsync(songs[1].Guid) .Returns(new ResponseInfo { Status = ResponseStatus.Success }.ToTaskResult()); var vm = new PlaylistViewModel(); vm.Activator.Activate(); await vm.LoadPlaylistCommand.ExecuteAsync(); vm.SelectedEntry = vm.Entries[1]; await vm.PlayPlaylistSongCommand.ExecuteAsync(); messenger.Received(1).PlayPlaylistSongAsync(songs[1].Guid); }
public async Task IsCurrentPlaylingSong() { var song = new NetworkSong { Title = "A" }; var playlist = new NetworkPlaylist { Name = "A", Songs = new List <NetworkSong> { song }.AsReadOnly(), CurrentIndex = 0 }; var messenger = CreateDefaultPlaylistMessenger(); messenger.GetCurrentPlaylistAsync().Returns(playlist.ToTaskResult()); var vm = new PlaylistViewModel(); vm.Activator.Activate(); await vm.LoadPlaylistCommand.ExecuteAsync(); Assert.Equal("A", vm.CurrentSong.Title); }
public void SmokeTest() { var songs = Helpers.SetupSongs(2); var playlist = new NetworkPlaylist { Name = "A", Songs = songs, CurrentIndex = 0 }; var messenger = CreateDefaultPlaylistMessenger(); messenger.GetCurrentPlaylistAsync().Returns(playlist.ToTaskResult()); messenger.PlayNextSongAsync().Returns(new ResponseInfo { Status = ResponseStatus.Success }.ToTaskResult()); var playlists = new Subject <NetworkPlaylist>(); messenger.PlaylistChanged.Returns(playlists); var vm = new PlaylistViewModel(); vm.Activator.Activate(); vm.LoadPlaylistCommand.Execute(null); var canExecute = vm.PlayNextSongCommand.CanExecuteObservable.CreateCollection(); vm.PlayNextSongCommand.Execute(null); playlists.OnNext(new NetworkPlaylist { Name = "A", Songs = songs, CurrentIndex = 1 }); playlists.OnNext(new NetworkPlaylist { Name = "A", Songs = songs, CurrentIndex = 0 }); playlists.OnNext(new NetworkPlaylist { Name = "A", Songs = songs, }); messenger.Received(1).PlayNextSongAsync(); Assert.Equal(new[] { true, false, true, false, true, false }, canExecute); }
public static JObject SerializePlaylist(Playlist playlist, AudioPlayerState playbackState, TimeSpan currentTime, TimeSpan totalTime) { var networkPlaylist = new NetworkPlaylist { Name = playlist.Name, CurrentIndex = playlist.CurrentSongIndex, Songs = playlist.Select(x => x.Song.ToNetworkSong(x.Guid)).ToList().AsReadOnly(), PlaybackState = (NetworkPlaybackState)Enum.ToObject(typeof(NetworkPlaybackState), (int)playbackState), CurrentTime = currentTime, TotalTime = totalTime }; return(JObject.FromObject(networkPlaylist)); }
public async Task <NetworkPlaylist> GetCurrentPlaylistAsync() { var playlist = new NetworkPlaylist { CurrentIndex = 4, CurrentTime = TimeSpan.FromSeconds(5), Name = "Party Playlist", PlaybackState = NetworkPlaybackState.Playing, Songs = new ReadOnlyCollection <NetworkSong>((await this.GetSongsAsync()).ToList()), TotalTime = TimeSpan.FromMinutes(3) }; return(playlist); }
public void SmokeTest() { var songs = Helpers.SetupSongs(2); var playlist = new NetworkPlaylist { Name = "A", Songs = songs, CurrentIndex = 1 }; var messenger = CreateDefaultPlaylistMessenger(); messenger.GetCurrentPlaylistAsync().Returns(playlist.ToTaskResult()); var vm = new PlaylistViewModel(); vm.Activator.Activate(); vm.LoadPlaylistCommand.Execute(null); Assert.Equal(playlist.Songs.Count, vm.Entries.Count); }
public void CanExecuteIsFalseForEmptyPlaylist() { var playlist = new NetworkPlaylist { Name = "A", Songs = new List <NetworkSong>().AsReadOnly(), CurrentIndex = 0 }; var messenger = CreateDefaultPlaylistMessenger(); messenger.GetCurrentPlaylistAsync().Returns(playlist.ToTaskResult()); messenger.PlayNextSongAsync().Returns(new ResponseInfo { Status = ResponseStatus.Success }.ToTaskResult()); var vm = new PlaylistViewModel(); vm.Activator.Activate(); vm.LoadPlaylistCommand.Execute(null); Assert.False(vm.PlayPreviousSongCommand.CanExecute(null)); }
public async Task PlaylistChangeUpdatesPlaylist() { var playlist = new NetworkPlaylist { Name = "A", Songs = new List <NetworkSong>().AsReadOnly() }; var messenger = CreateDefaultPlaylistMessenger(); messenger.GetCurrentPlaylistAsync().Returns(playlist.ToTaskResult()); var songs = Helpers.SetupSongs(2); var changedPlaylist = new NetworkPlaylist { Name = "B", Songs = songs, CurrentIndex = 1 }; var playlistChanged = new Subject <NetworkPlaylist>(); messenger.PlaylistChanged.Returns(playlistChanged); var vm = new PlaylistViewModel(); vm.Activator.Activate(); await vm.LoadPlaylistCommand.ExecuteAsync(); playlistChanged.OnNext(changedPlaylist); Assert.Equal(1, changedPlaylist.CurrentIndex); //Assert.Equal(playlist.Name, vm.Name); Assert.Equal(changedPlaylist.Songs.Count, vm.Entries.Count); }