public void GivenMessage_UpdatesState()
            {
                const string newState = "updated";

                _reducer = new FakeReducer <string>(ReduceToNewState);

                Store.Dispatch(_message);
                Store.State.Should().Be(newState);
            public void GivenNullMessage_ThrowsException()
            {
                _reducer = new FakeReducer <string>((_, s) => s);
                var exception =
                    Assert.Throws <ArgumentNullException>(
                        () => Store.Dispatch(null !));

                exception.ParamName.Should().Be("message");
            }
            public void GivenMessage_CallsReducerWithState()
            {
                _reducer = new FakeReducer <string>(CaptureState);
                string initialState  = Store.State;
                string receivedState = null !;

                Store.Dispatch(_message);
                receivedState.Should().Be(initialState);

                string CaptureState(IReduxMessage _, string state)
                {
                    receivedState = state;
                    return(state);
                }
            }
            public void GivenMessage_CallsReducerWithMessage()
            {
                FakeMessage?receivedMessage = null;

                _reducer = new FakeReducer <string>(CaptureMessage);

                Store.Dispatch(_message);
                receivedMessage.Should().Be(_message);

                string CaptureMessage(IReduxMessage message, string state)
                {
                    receivedMessage = message as FakeMessage;
                    return(state);
                }
            }
 public ReduxMiddlewareTests()
 {
     _incrementingReducer = new FakeReducer <int>(Incrementer);
     _store = new ReduxStore <int>(_incrementingReducer, stateFactory);
 }
 public void GivenInitialState_InitializesProperty()
 {
     _reducer = new FakeReducer <string>(IgnoreMessages);
     Store.State.Should().Be(_initialStateFactory.State);
 }