RemoveSoundsCommandExecute_SoundBoardIsNotNullAndParameterIsIListWith3Sounds_RemovesThoseSoundsFromSelectedSoundboard () { //Arrange var selectedSounds = new List <ISound> { MockRepository.GenerateStub <ISound>(), MockRepository.GenerateStub <ISound>(), MockRepository.GenerateStub <ISound>() }; var stub = MockRepository.GenerateStub <IMainWindowViewModel>(); stub.SelectedSoundBoard = new SoundBoard.Model.SoundBoard { Sounds = new ObservableCollection <ISound>(selectedSounds) { MockRepository.GenerateStub <ISound>(), MockRepository.GenerateStub <ISound>() } }; Target = CreateTargetWithDefaultStubs(stub); //Act Target.RemoveSoundsCommand.Execute(selectedSounds); //Assert stub.SelectedSoundBoard.Sounds .Should().NotContain(selectedSounds) .And.HaveCount(2); }
public void RemoveSoundsCommandCanExecute_SoundBoardIsNotNullAndParameterIsIListWith1Sound_ReturnsTrue() { var stub = MockRepository.GenerateStub <IMainWindowViewModel>(); stub.SelectedSoundBoard = new SoundBoard.Model.SoundBoard(); Target = CreateTargetWithDefaultStubs(stub); Target.RemoveSoundsCommand.CanExecute(new Collection <ISound> { MockRepository.GenerateStub <ISound>() }) .Should().BeTrue(); }
private SoundContextMenuCommands CreateTargetWithDefaultStubs( IMainWindowViewModel mainWindowViewModel = null, IDialogService dialogService = null, IKernel container = null) { if (container == null) { container = new StandardKernel(); container.Bind <MainWindow>().ToMethod(context => new MainWindow()); } SoundContextMenuCommands soundContextMenuCommands = new SoundContextMenuCommands( mainWindowViewModel ?? MockRepository.GenerateStub <IMainWindowViewModel>(), dialogService ?? MockRepository.GenerateStub <IDialogService>(), container); return(soundContextMenuCommands); }
public void RenameSoundCommandExecute_DialogReturnsNull_OldNameIsRetained() { //Arrange const string expected = "Old Name"; ISound selectedSound = CommonStubsFactory.StubClonableSound("Old Name"); IDialogService stub = MockRepository.GenerateStub <IDialogService>(); Target = CreateTargetWithDefaultStubs(dialogService: stub); stub.Stub(service => service.NameDialog(null, null, null, null)).IgnoreArguments().Return(null); //Act Target.RenameSoundCommand.Execute(new Collection <ISound> { selectedSound }); //Assert selectedSound.Name.Should().Be(expected); }
public void RenameSoundCommandExecute__NameDialogIsCalledWithTitlePromptAndInitialName() { ISound selectedSound = CommonStubsFactory.StubClonableSound("Old Name"); IDialogService mock = MockRepository.GenerateMock <IDialogService>(); Target = CreateTargetWithDefaultStubs(dialogService: mock); mock.Expect(service => service.NameDialog( Arg <Window> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Anything, Arg <string> .Is.Equal(selectedSound.Name))) .Return(null); //Act Target.RenameSoundCommand.Execute(new Collection <ISound> { selectedSound }); //Assert mock.VerifyAllExpectations(); }
public void ActivateSoundsCommandExecute_ParameterContainsIListWith3Sounds_Adds3EquivalentClonesToActiveSounds() { //Arrange List <ISound> selectedSounds = new List <ISound> { CommonStubsFactory.StubClonableSoundWithRandomName(), CommonStubsFactory.StubClonableSoundWithRandomName(), CommonStubsFactory.StubClonableSoundWithRandomName() }; IMainWindowViewModel mainWindowViewModel = CommonStubsFactory.StubMainWindowViewModel(); Target = CreateTargetWithDefaultStubs(mainWindowViewModel); //Act Target.ActivateSoundsCommand.Execute(selectedSounds); //Assert for (var i = 0; i < selectedSounds.Count; i++) { mainWindowViewModel.SoundService.ActiveSounds[i].ShouldBeEquivalentTo(selectedSounds[i], "for each selected sound there must be an identical active sound"); mainWindowViewModel.SoundService.ActiveSounds[i].Should().NotBeSameAs(selectedSounds[i], "it must be a clone, not the same reference"); } }
public void InitializeBeforeEachTest() { Target = CreateTargetWithDefaultStubs(); }