Exemple #1
0
        public void WhenCallToDispose_UnsubscribeFromEventDispatch()
        {
            var inGamePresenter = new InGamePresenter(_inGameViewModel, _eventDispatcherService);

            _eventDispatcherService.ClearReceivedCalls();
            inGamePresenter.Dispose();

            _eventDispatcherService.Received(1).Unsubscribe <NewWordSignal>(Arg.Any <SignalDelegate>());
            _eventDispatcherService.Received(1).Unsubscribe <GuessResultSignal>(Arg.Any <SignalDelegate>());
            _eventDispatcherService.Received(1).Unsubscribe <WordCompletedSignal>(Arg.Any <SignalDelegate>());
            _eventDispatcherService.Received(1).Unsubscribe <RestartGameSignal>(Arg.Any <SignalDelegate>());
            _eventDispatcherService.Received(1).Unsubscribe <GameOverSignal>(Arg.Any <SignalDelegate>());
            Assert.AreEqual(5, _eventDispatcherService.ReceivedCalls().Count());
        }
        public void WhenCallToStart_DispatchSignalWithTheNewWord()
        {
            _gameService.StartNewGame().Returns(info =>
                                                new Tuple <Word, Token>
                                                (
                                                    WordFactory.GetWord.WithValue("word"),
                                                    TokenFactory.GetToken
                                                ));

            _startGameUseCase.Start();

            _eventDispatcherService
            .Received()
            .Dispatch(Arg.Is <NewWordSignal>(signal => signal.NewWord == "word"));
        }
Exemple #3
0
        public void WhenCallToRestart_DispatchRestartGameSignal()
        {
            _restartGameUseCase.Restart();

            _eventDispatcherService
            .Received()
            .Dispatch(Arg.Any <RestartGameSignal>());
        }
        public void WhenCallToStart_DispatchSignalToUpdateTheLoadingScreen()
        {
            _guessLetterUseCase.Guess('A');

            Received.InOrder(() =>
            {
                _eventDispatcherService
                .Received()
                .Dispatch(Arg.Is <UpdateLoadingScreenSignal>(signal => signal.IsVisible));

                _gameService.Received().GuessLetter(Arg.Any <char>());

                _eventDispatcherService
                .Received()
                .Dispatch(Arg.Is <UpdateLoadingScreenSignal>(signal => !signal.IsVisible));
            });
        }