public void ApplyShouldWorkOnSelectedPropertyOfImmutableState() { ImmutableTree state = new ImmutableTree(1, false); ReducerComposer <ImmutableTree> composer = new ReducerComposer <ImmutableTree>(); composer.AddSubTreeReducer(new ImmutableIntPropReducer()) .AddSubTreeReducer(new ImmutableBoolPropReducer()); state = composer.Apply(state, ""); Assert.AreEqual(2, state.IntProp); Assert.AreEqual(true, state.BoolProp); }
public void ApplyShowForwardCallToRegisteredReducer() { Mock <IReducer <TestState> > mockIReducer = new Mock <IReducer <TestState> >(); mockIReducer.Setup(x => x.Apply(It.IsAny <TestState>(), It.IsAny <object>())).Returns(new TestState()); ReducerComposer <TestState> composer = new ReducerComposer <TestState>(); composer.AddStateReducer(mockIReducer.Object); var result = composer.Apply(new TestState(), ""); mockIReducer.Verify(x => x.Apply(It.IsAny <TestState>(), It.IsAny <object>())); }
public void ApplyShouldWorkOnSelectedPropertyOfState() { Tree state = new Tree(); state.IntProp = 1; state.BoolProp = false; ReducerComposer <Tree> composer = new ReducerComposer <Tree>(); composer.AddSubTreeReducer(new IntPropReducer()) .AddSubTreeReducer(new BoolPropReducer()); composer.Apply(state, ""); Assert.AreEqual(2, state.IntProp); Assert.AreEqual(true, state.BoolProp); }