예제 #1
0
        public static IMainWindowViewModel StubMainWindowViewModel(IObservableSoundService observableSoundService = null, ObservableCollection <ISound> initialSounds = null)
        {
            IMainWindowViewModel mainWindowViewModel = MockRepository.GenerateStub <IMainWindowViewModel>();

            mainWindowViewModel.Stub(model => model.SoundService)
            .Return(observableSoundService ?? StubObservableSoundService(initialSounds));

            return(mainWindowViewModel);
        }
 public MainWindowViewModel(ISoundBoardRepository soundBoardRepository, IDialogService dialogService,
                            IObservableSoundService soundService, IKernel container,
                            ISoundFactory soundFactory)
 {
     _soundBoardRepository = soundBoardRepository;
     _dialogService        = dialogService;
     _container            = container;
     _soundFactory         = soundFactory;
     SoundService          = soundService;
     Commands = new CommandsRepository(this, _soundFactory);
     SoundContextMenuCommands       = new SoundContextMenuCommands(this, _dialogService, container);
     ActiveSoundContextMenuCommands = new ActiveSoundContextMenuCommands(this);
     LoadSoundBoards();
 }
예제 #3
0
        public void ActivateSingleSoundCommand_ParameterIsNotNull_AddsCloneOfSoundToActiveSounds()
        {
            //Arrange
            ObservableCollection <ISound> activeSounds           = new ObservableCollection <ISound>();
            IObservableSoundService       observableSoundService = CommonStubsFactory.StubObservableSoundService(activeSounds);

            Target = CreateTarget(soundService: observableSoundService);
            ISound sound = CommonStubsFactory.StubClonableSoundWithRandomName();

            //Act
            Target.Commands.ActivateSingleSoundCommand.Execute(sound);

            //Assert
            activeSounds.Should().NotContain(s => ReferenceEquals(s, sound));
            activeSounds.Single().ShouldBeEquivalentTo(sound);
        }
예제 #4
0
        public static IObservableSoundService StubObservableSoundService(ObservableCollection <ISound> initialCollection = null)
        {
            ObservableCollection <ISound> activeSounds = initialCollection ?? new ObservableCollection <ISound>();

            IObservableSoundService observableSoundService = MockRepository.GenerateStub <IObservableSoundService>();

            observableSoundService.Stub(service => service.ActiveSounds)
            .Return(new ReadOnlyObservableCollection <ISound>(activeSounds));

            observableSoundService.Stub(service => service.Add(Arg <ISound> .Is.NotNull))
            .WhenCalled(invocation => activeSounds.Add((ISound)invocation.Arguments.First()));

            observableSoundService.Stub(service => service.Remove(Arg <ISound> .Is.NotNull))
            .WhenCalled(invocation => activeSounds.Remove((ISound)invocation.Arguments.First()));

            return(observableSoundService);
        }
예제 #5
0
        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" })));
        }