コード例 #1
0
        public void SubTreeToFullTreeAdapterShouldWorkWhenStateHasStaticProperties()
        {
            var target   = new SubTreeToFullTreeAdapter <AppState, int>(new IdReducer());
            var newState = target.Apply(AppState.InitialState, 1);

            Assert.AreEqual(1, newState.Id);
        }
コード例 #2
0
        public void ApplyShouldWorkOnSelectedPropertyOfImmutableState()
        {
            ImmutableTree state = new ImmutableTree(1, false);

            SubTreeToFullTreeAdapter <ImmutableTree, int>  adapter1 = new SubTreeToFullTreeAdapter <ImmutableTree, int>(new ImmutableIntPropReducer());
            SubTreeToFullTreeAdapter <ImmutableTree, bool> adapter2 = new SubTreeToFullTreeAdapter <ImmutableTree, bool>(new ImmutableBoolPropReducer());

            state = adapter1.Apply(state, "");
            state = adapter2.Apply(state, "");
            Assert.AreEqual(2, state.IntProp);
            Assert.AreEqual(true, state.BoolProp);
        }
コード例 #3
0
        public void ApplyShouldWorkOnSelectedPropertyOfState()
        {
            Tree state = new Tree();

            state.IntProp  = 1;
            state.BoolProp = false;
            SubTreeToFullTreeAdapter <Tree, int>  adapter1 = new SubTreeToFullTreeAdapter <Tree, int>(new IntPropReducer());
            SubTreeToFullTreeAdapter <Tree, bool> adapter2 = new SubTreeToFullTreeAdapter <Tree, bool>(new BoolPropReducer());

            adapter1.Apply(state, "");
            adapter2.Apply(state, "");
            Assert.AreEqual(2, state.IntProp);
            Assert.AreEqual(true, state.BoolProp);
        }