示例#1
0
        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);
        }
示例#2
0
        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>()));
        }
示例#3
0
        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);
        }