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();
 }
Beispiel #2
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" })));
        }
Beispiel #3
0
        public void SaveDataCommandExecute_QuestionDialogResultIsFalse_DoesNotCallSaveSoundBoards()
        {
            //Arrange
            IDialogService stub = MockRepository.GenerateStub <IDialogService>();

            stub.Stub(service => service.QuestionDialog(null, null, null)).IgnoreArguments().Return(false);

            ISoundBoardRepository mock = MockRepository.GenerateMock <ISoundBoardRepository>();

            mock.Expect(repository => repository.SetSoundBoards(null)).IgnoreArguments()
            .Repeat.Never();

            Target = CreateTarget(dialogService: stub, soundBoardRepository: mock);

            //Act
            Target.Commands.ShutdownAppCommand.Execute(null);

            //Assert
            mock.VerifyAllExpectations();
        }
Beispiel #4
0
        public void SaveDataCommandExecute_AreSoundBoardsChangedReturnsTrue_QuestionDialogIsCalled()
        {
            //Arrange
            ISoundBoardRepository stub = MockRepository.GenerateStub <ISoundBoardRepository>();

            stub.Stub(repository => repository.AreSoundBoardsDifferent(null)).IgnoreArguments().Return(true);

            IDialogService mock = MockRepository.GenerateMock <IDialogService>();

            mock.Expect(service => service.QuestionDialog(null, null, null))
            .IgnoreArguments()
            .Return(false);

            Target = CreateTarget(dialogService: mock, soundBoardRepository: stub);

            //Act
            Target.Commands.ShutdownAppCommand.Execute(null);

            //Assert
            mock.VerifyAllExpectations();
        }