public void ChangeFolderCommandHandler_IfDiscItemIsSelected_DoesNothing() { // Arrange var folder = new FolderModel(); folder.AddSubfolders(new FolderModel { Id = new ItemId("Subfolder Id") }); folder.AddDiscs(new DiscModel { TreeTitle = "Some Disc" }.MakeActive()); var parentFolder = new FolderModel { Id = new ItemId("Parent Folder Id") }; parentFolder.AddSubfolders(folder); var mocker = new AutoMocker(); var target = mocker.CreateInstance <LibraryExplorerItemListViewModel>(); target.LoadFolderItems(folder); target.SelectedItem = target.Items[2]; target.SelectedItem.Should().BeOfType <DiscExplorerItem>(); LoadParentFolderEventArgs loadParentFolderEvent = null; Messenger.Default.Register <LoadParentFolderEventArgs>(this, e => e.RegisterEvent(ref loadParentFolderEvent)); LoadFolderEventArgs loadFolderEvent = null; Messenger.Default.Register <LoadFolderEventArgs>(this, e => e.RegisterEvent(ref loadFolderEvent)); // Act target.ChangeFolderCommand.Execute(null); // Assert loadParentFolderEvent.Should().BeNull(); loadFolderEvent.Should().BeNull(); }
public void LoadFolderEventHandler_LoadsFolderCorrectly() { // Arrange var folder = new FolderModel { Id = new ItemId("Some Folder Id") }; var loadFolderEvent = new LoadFolderEventArgs(folder); var mocker = new AutoMocker(); var target = mocker.CreateInstance <LibraryExplorerViewModel>(); // Act Messenger.Default.Send(loadFolderEvent); // Assert var itemListViewModelMock = mocker.GetMock <ILibraryExplorerItemListViewModel>(); itemListViewModelMock.Verify(x => x.LoadFolderItems(folder), Times.Once); itemListViewModelMock.Verify(x => x.SelectFolder(It.IsAny <ItemId>()), Times.Never); }