Esempio n. 1
0
        public void WhenDispatchGuessResultSignal_UpdateGallowVisibilityViewModel()
        {
            SignalDelegate callback = null;

            _eventDispatcherService
            .When(service => service.Subscribe <GuessResultSignal>(Arg.Any <SignalDelegate>()))
            .Do(info => callback = info.Arg <SignalDelegate>());
            var isEnabledObserver1 = Substitute.For <IObserver <bool> >();

            _inGameViewModel.IsGallowPartVisible.Clear();
            var gallowImageProperty1 = _inGameViewModel.SubscribeGallowImage();

            gallowImageProperty1.Subscribe(isEnabledObserver1);
            isEnabledObserver1.ClearReceivedCalls();
            var isEnabledObserver2   = Substitute.For <IObserver <bool> >();
            var gallowImageProperty2 = _inGameViewModel.SubscribeGallowImage();

            gallowImageProperty2.Subscribe(isEnabledObserver2);
            isEnabledObserver2.ClearReceivedCalls();
            var inGamePresenter = new InGamePresenter(_inGameViewModel, _eventDispatcherService);

            callback(new GuessResultSignal(_letterToGuess, "word", true));
            callback(new GuessResultSignal(_letterToGuess, "word", false));
            callback(new GuessResultSignal(_letterToGuess, "word", true));
            callback(new GuessResultSignal(_letterToGuess, "word", false));
            callback(new GuessResultSignal(_letterToGuess, "word", true));

            Received.InOrder(() =>
            {
                isEnabledObserver1.Received().OnNext(true);
                isEnabledObserver2.Received().OnNext(true);
            });
        }
Esempio n. 2
0
        public void SetUp()
        {
            _inGameViewModel = Substitute.For <InGameViewModel>();
            _inGameViewModel.SubscribeGallowImage();
            _colorObserver        = Substitute.For <IObserver <string> >();
            _isKetEnabledObserver = Substitute.For <IObserver <bool> >();
            _letterToGuess        = "d";
            _keyButtonViewModel   = _inGameViewModel.SubscribeKeyButton(_letterToGuess);
            _keyButtonViewModel.Color.Subscribe(_colorObserver);
            _keyButtonViewModel.IsEnabled.Subscribe(_isKetEnabledObserver);


            _eventDispatcherService = Substitute.For <IEventDispatcherService>();
        }