コード例 #1
0
        public void TestValidationModeratorAnd()
        {
            var moderator = new FarmVisitor();
            var result    = moderator.Visit(GetModelWhenCardsAndMinerChecked(LocicalBinaryOperator.and));

            Assert.AreEqual(result.IsValid, false);
        }
コード例 #2
0
        public void TestValidationModerator()
        {
            var moderator = new FarmVisitor();
            var result    = moderator.Validate(GetModelWhenCardsAndMinerChecked(LocicalBinaryOperator.or), FakeState());

            Assert.AreEqual(result.IsValid, true);
        }
コード例 #3
0
        public void TestSerializationModerator()
        {
            var seria     = BinarySerializer.SerializeToString(GetModelWhenCardsAndMinerChecked(LocicalBinaryOperator.or));
            var deSeria   = BinarySerializer.DeserializeFromString <IBaseConditionModel>(seria);
            var moderator = new FarmVisitor();
            var result    = moderator.Validate(deSeria, FakeState());

            Assert.AreEqual(result.IsValid, true);
        }
コード例 #4
0
        public void TestValidationCoolectionAnyModerator()
        {
            var model = new UnaryOperation()
            {
                Operand = new PropertyCollectionOperation
                {
                    Collection = new[]
                    {
                        new ContextProperty {
                            DynamicValue = (ctx) => ctx.Card(1, x => x.TempLimit.Current)
                        },
                        new ContextProperty {
                            DynamicValue = (ctx) => ctx.Card(2, x => x.TempLimit.Current)
                        },
                        new ContextProperty {
                            DynamicValue = (ctx) => ctx.Card(3, x => x.TempLimit.Current)
                        },
                        new ContextProperty {
                            DynamicValue = (ctx) => ctx.Card(4, x => x.TempLimit.Current)
                        },
                        new ContextProperty {
                            DynamicValue = (ctx) => ctx.Card(5, x => x.TempLimit.Current)
                        },
                    },
                    Operator = CollectionOperator.Contains,
                    Property = new BaseProperty
                    {
                        Value = 0
                    }
                }
            };
            var moderator = new FarmVisitor();
            var result    = moderator.Validate(model, FakeState());

            Assert.AreEqual(result.IsValid, true);
        }