public void AddSoundCommandExecute__CallsDialogServiceOpenFileDialogWithCorrectArguments() { //Arrange IDialogService dialogServiceMock = MockRepository.GenerateMock <IDialogService>(); string[] supportedExtensions = { "*.a", "*.b", "*.c" }; Dictionary <string, string> expectedFilters = new Dictionary <string, string> { { Properties.Resources.MainWindowViewModel_AddSounds_Supported_Files, string.Join(Properties.Resources.MainWindowViewModel_AddSounds__Supported_Files_Separator, supportedExtensions) } }; Target = CreateTarget(dialogService: dialogServiceMock, soundFactory: CommonStubsFactory.StubSoundFactory(supportedExtensions)); Target.SelectedSoundBoard = new SoundBoard.Model.SoundBoard(); dialogServiceMock.Expect( service => service.OpenFileDialog(Properties.Resources.MainWindowViewModel_AddSounds_Choose_sound_files_to_add, expectedFilters)) .Return(Enumerable.Empty <string>()); //Act Target.Commands.AddSoundCommand.Execute(null); //Assert dialogServiceMock.VerifyAllExpectations(); }
private static MainWindowViewModel CreateTarget(ISoundBoardRepository soundBoardRepository = null, IDialogService dialogService = null, IKernel container = null, IObservableSoundService soundService = null, ISoundFactory soundFactory = null) { if (container == null) { container = new StandardKernel(); container.Bind <MainWindow>().ToMethod(context => new MainWindow()); } return(new MainWindowViewModel( soundBoardRepository ?? MockRepository.GenerateStub <ISoundBoardRepository>(), dialogService ?? MockRepository.GenerateStub <IDialogService>(), soundService ?? CommonStubsFactory.StubObservableSoundService(), container, soundFactory ?? CommonStubsFactory.StubSoundFactory(new string[] { "*.a", "*.b" }))); }
public void Drop_EffectIsCopyAndTargetCollectionIsActiveSoundsDataIsADataObjectContainingMultipleFiles_AddsASoundForEachSupportedFileToSoundService() { //Arrange ISoundFactory soundFactory = CommonStubsFactory.StubSoundFactory(new string[] { "*.mp3", "*.m4a", "*.ogg" }); Target = CreateTarget(soundFactory: soundFactory); ICollection <ISound> targetCollection = Target.SoundService.ActiveSounds; DataObject droppeDataObject = new DataObject(); string[] supportedFiles = { "Taking the hobbits to isengard.mp3", "The way i tend to be.m4a", "-Human.ogg" }; StringCollection fileDropList = new StringCollection { "Unsupported File.wav", "Unsupported File2.agg", "Unsupported File2.bleurrg", "Unsupported File2.idk" }; fileDropList.AddRange(supportedFiles); droppeDataObject.SetFileDropList(fileDropList); IDropInfo dropInfo = MockRepository.GenerateStub <IDropInfo>(); dropInfo.Effects = DragDropEffects.Copy; dropInfo.Stub(info => info.TargetCollection).Return(targetCollection); dropInfo.Stub(info => info.Data).Return(droppeDataObject); //Act Target.Drop(dropInfo); //Assert targetCollection.Should().OnlyContain(sound => supportedFiles.Any(s => s == sound.FileName)); }