public void PlaylistChangedEventHandler_IfDiscSongListIsSelected_DoesNotRaiseActiveDiscChangedEvent() { // Arrange var mocker = new AutoMocker(); // Mocking SelectedDisc for LibraryExplorer so that we could catch mistaken set of ActiveDisc to different value. mocker.GetMock <ILibraryExplorerViewModel>() .Setup(x => x.SelectedDisc).Returns(new DiscModel()); var target = mocker.CreateInstance <SongListTabViewModel>(); target.SwitchToDiscSongListCommand.Execute(null); ActiveDiscChangedEventArgs activeDiscChangedEventArgs = null; Messenger.Default.Register <ActiveDiscChangedEventArgs>(this, e => e.RegisterEvent(ref activeDiscChangedEventArgs)); // Act Messenger.Default.Send(new PlaylistChangedEventArgs(Enumerable.Empty <SongModel>(), null, null)); // Assert activeDiscChangedEventArgs.Should().BeNull(); }
public void SwitchToDiscSongListCommand_IfSongListIsChanged_RaisesActiveDiscChangedEventForSelectedDisc() { // Arrange var selectedDisc = new DiscModel(); var mocker = new AutoMocker(); mocker.GetMock <ILibraryExplorerViewModel>() .Setup(x => x.SelectedDisc).Returns(selectedDisc); var target = mocker.CreateInstance <SongListTabViewModel>(); target.SwitchToPlaylistCommand.Execute(null); ActiveDiscChangedEventArgs activeDiscChangedEventArgs = null; Messenger.Default.Register <ActiveDiscChangedEventArgs>(this, e => e.RegisterEvent(ref activeDiscChangedEventArgs)); // Act target.SwitchToDiscSongListCommand.Execute(null); // Assert activeDiscChangedEventArgs.Should().NotBeNull(); activeDiscChangedEventArgs.Disc.Should().Be(selectedDisc); }
public void PlaylistChangedEventHandler_IfPlaylistIsSelected_RaisesActiveDiscChangedEventForCurrentPlaylistDisc() { // Arrange var currentDisc = new DiscModel(); var mocker = new AutoMocker(); var target = mocker.CreateInstance <SongListTabViewModel>(); target.SwitchToPlaylistCommand.Execute(null); // We mock CurrentDisc property after switching to Playlist. // Otherwise value of ActiveDisc will be the same and no event will be sent. mocker.GetMock <IPlaylistViewModel>() .Setup(x => x.CurrentDisc).Returns(currentDisc); ActiveDiscChangedEventArgs activeDiscChangedEventArgs = null; Messenger.Default.Register <ActiveDiscChangedEventArgs>(this, e => e.RegisterEvent(ref activeDiscChangedEventArgs)); // Act Messenger.Default.Send(new PlaylistChangedEventArgs(Enumerable.Empty <SongModel>(), null, null)); // Assert activeDiscChangedEventArgs.Should().NotBeNull(); activeDiscChangedEventArgs.Disc.Should().Be(currentDisc); }