protected void VisitChildren()
 {
     Test         = TestCondition.AcceptVisitor(Visitor, ParentScope);
     IfTrue       = TrueCondition.AcceptVisitor(Visitor, ParentScope);
     IfFalse      = FalseCondition.AcceptVisitor(Visitor, ParentScope);
     InternalType = IfTrue.Type;
 }
Example #2
0
        public void ConstructorTest()
        {
            FalseCondition target = new FalseCondition();

            // TODO: Implement code to verify target
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
Example #3
0
        public void AcceptTest()
        {
            FalseCondition target = new FalseCondition();

            IVisitor visitor = null; // TODO: Initialize to an appropriate value

            target.Accept(visitor);

            Assert.Inconclusive("A method that does not return a value cannot be verified.");
        }
Example #4
0
        private void addPurchasingPolicyFalse()
        {
            bridge.Login(getStoreOwner1(), password);
            IBooleanExpression policy = new FalseCondition();
            string             json   = JsonHandler.SerializeObject(policy);

            bridge.addPurchasingPolicy(storeId, json);
            //TODO: not a number may couse prolems in the future
            policyId = 0;
            Assert.IsTrue(policyId >= 0);
        }
Example #5
0
        public void Test___Method_Check___Value_True()
        {
            var testee = new FalseCondition {
                Value = new AnyVariable <bool>()
                {
                    Value = true
                }
            };

            Assert.IsFalse(testee.Check());
        }
Example #6
0
        public void addStorePolicyTest()
        {
            storeExp = new FalseCondition();
            int oldNumPolicies = store.storePolicies.Count;

            Policystatus status = PolicyService.addStorePolicy(storeOwner, idStore, storeExp);

            Assert.IsTrue(status == Policystatus.Success);

            IBooleanExpression policy = store.getPolicy(-1);

            idstoreExp = policy.id;
            Assert.IsTrue(idstoreExp >= 0, idstoreExp + "");
            int newNumPolicies = store.storePolicies.Count;

            Assert.AreNotEqual(oldNumPolicies, newNumPolicies);
        }
        public void checkConsistency()
        {
            int            min = 10, max = 5;
            TrueCondition  trueCondition  = new TrueCondition();
            FalseCondition falseCondition = new FalseCondition();

            Assert.IsFalse(trueCondition.checkConsistent(falseCondition), "1");
            Assert.IsFalse(falseCondition.checkConsistent(trueCondition), "2");

            MinAmount minAmount = new MinAmount(min, new AllProductsFilter());
            MaxAmount maxAmount = new MaxAmount(max, new AllProductsFilter());

            Assert.IsFalse(minAmount.checkConsistent(maxAmount), "3");
            Assert.IsFalse(maxAmount.checkConsistent(minAmount), "4");

            List <IBooleanExpression> list = new List <IBooleanExpression>();

            list.Add(trueCondition);
            list.Add(minAmount);

            Assert.IsFalse(IBooleanExpression.confirmListConsist(falseCondition, list));
            Assert.IsFalse(IBooleanExpression.confirmListConsist(maxAmount, list));

            List <int> list1 = new List <int>();

            list1.Add(1);
            List <int> list2 = new List <int>();

            list2.Add(2);
            ProductListFilter f1         = new ProductListFilter(list1);
            ProductListFilter f2         = new ProductListFilter(list2);
            MinAmount         minAmount2 = new MinAmount(min, f1);
            MaxAmount         maxAmount2 = new MaxAmount(max, f2);

            Assert.IsFalse(maxAmount.checkConsistent(minAmount2));
            Assert.IsTrue(maxAmount2.checkConsistent(minAmount2));
            f2.productIds = list1;
            Assert.IsFalse(maxAmount2.checkConsistent(minAmount2));

            minAmount.amount = max;
            maxAmount.amount = min;
            Assert.IsTrue(minAmount.checkConsistent(maxAmount), "5");
        }
        public void ANDevaluateTest()
        {
            FalseCondition falseCondition = new FalseCondition();
            TrueCondition  trueCondition  = new TrueCondition();

            AndExpression and = new AndExpression();

            and.addChildren(trueCondition, trueCondition);
            Assert.IsTrue(and.evaluate(list, user));

            and.addChildren(falseCondition, trueCondition);
            Assert.IsFalse(and.evaluate(list, user));

            and.addChildren(trueCondition, falseCondition);
            Assert.IsFalse(and.evaluate(list, user));

            and.addChildren(falseCondition, falseCondition);
            Assert.IsFalse(and.evaluate(list, user));
        }
        public void XORevaluateTest()
        {
            FalseCondition falseCondition = new FalseCondition();
            TrueCondition  trueCondition  = new TrueCondition();

            XorExpression xor = new XorExpression();

            xor.addChildren(trueCondition, trueCondition);
            Assert.IsFalse(xor.evaluate(list, user));

            xor.addChildren(trueCondition, falseCondition);
            Assert.IsTrue(xor.evaluate(list, user));

            xor.addChildren(falseCondition, trueCondition);
            Assert.IsTrue(xor.evaluate(list, user));

            xor.addChildren(falseCondition, falseCondition);
            Assert.IsFalse(xor.evaluate(list, user));
        }
    /// <summary>
    /// Creates Game1.
    /// </summary>
    public GMGame CreateGame1()
    {
        //create games and add triggers
        GMGame game = new GMGame("game1");

        //create conditions
        ACondition cond1 = new TestCondition("Test-Cond-1", true);
        //ACondition cond2 = new TestCondition("Test-Cond-2", true);
        ACondition falseCond = new FalseCondition();
        ACondition trueCond = new TrueCondition();
        ACondition relTimeCond = new TimerCondition(TimerType.Relative, 1, game.TimeSource);  //true after 1sec

        //create triggers
        ScriptTrigger<int> trigger1 = new ScriptTrigger<int>(
               2, 500,
               trueCond.Check, null, TestScriptFunctionInt, 111);

        ScriptTrigger<int> trigger2 = new ScriptTrigger<int>();
        trigger2.Value = 222;
        trigger2.Function = TestScriptFunctionInt;
        trigger2.Priority = 3;
        trigger2.Repeat = 3;
        trigger2.FireCondition = cond1.Check;

        //this will only be fired, when both fireCondition is true at the same time
        ScriptTrigger<string> trigger3 = new ScriptTrigger<string>();
        trigger3.Value = "game2";
        trigger3.Function = TestScriptFunctionString;
        trigger3.Priority = 1;
        trigger3.Repeat = 1;							//only fire once
        trigger3.FireCondition += trueCond.Check;		//always true, but you can check sg extra here
        trigger3.FireCondition += relTimeCond.Check;	//should fire only when time reached
        trigger3.DeleteCondition = falseCond.Check;		//don't remove until repeating

        game.AddTrigger(trigger1);
        game.AddTrigger(trigger2);
        Debug.Log ("Added trigger 3");
        game.AddTrigger(trigger3);

        return game;
    }
Example #11
0
        public void removeDiscountPolicyTest()
        {
            IOutcome           outcome = new Percentage(20);
            IBooleanExpression exp     = new FalseCondition();

            discount = new Discount(exp, outcome);
            Policystatus status = PolicyService.addDiscountPolicy(storeOwner, idStore, discount);

            Assert.IsTrue(status == Policystatus.Success);
            Discount theNewDiscount = store.getDiscountPolicy(-1);

            idDiscount = theNewDiscount.id;

            int oldNumPolicies = store.discountPolicies.Count;

            status = PolicyService.removeDiscountPolicy(storeOwner, idStore, idDiscount);
            Assert.IsTrue(status == Policystatus.Success);
            int newNumPolicies = store.discountPolicies.Count;

            Assert.AreNotEqual(oldNumPolicies, newNumPolicies);
        }
    /// <summary>
    /// Creates Game2.
    /// </summary>
    public GMGame CreateGame2()
    {
        //create conditions
        ACondition falseCond = new FalseCondition();
        ACondition trueCond = new TrueCondition();
        ScriptCondition<bool> scriptCond =  new ScriptCondition<bool>(TestScriptConditionEvaulateBool, true);

        //create triggers
        ScriptTrigger<int> trigger1 = new ScriptTrigger<int>(2, 2, trueCond.Check, trueCond.Check, TestScriptFunctionInt, 1);
        ScriptTrigger<float> trigger2 = new ScriptTrigger<float>(5, 10, trueCond.Check, falseCond.Check, TestScriptFunctionFloat, 2.2f);
        ScriptTrigger<string> trigger3 = new ScriptTrigger<string>(1, 3, null, null, TestScriptFunctionString, "no conditions");
        DialogTrigger trigger4 = new DialogTrigger(1, 3, scriptCond.Check, null, "myDialog");

        //create games and add triggers
        GMGame game = new GMGame("game2");
        game.AddTrigger(trigger1);
        game.AddTrigger(trigger2);
        game.AddTrigger(trigger3);
        game.AddTrigger(trigger4);

        return game;
    }
Example #13
0
        public void Test___Method_Check___Value_null()
        {
            var testee = new FalseCondition();

            Assert.IsFalse(testee.Check());
        }
        public void FalseevaluateTest()
        {
            FalseCondition falseCondition = new FalseCondition();

            Assert.IsFalse(falseCondition.evaluate(list, user));
        }
Example #15
0
 /// <summary>
 /// Visits the false.
 /// </summary>
 /// <remarks>
 /// Generate a 0, a false value.
 /// </remarks>
 /// <param name="f">The f.</param>
 public void VisitFalse(FalseCondition falseObject)
 {
     Instructions.Add(Worker.Create(OpCodes.Ldc_I4_0));
 }