Beispiel #1
0
        public void ConstructorTest()
        {
            TrueCondition target = new TrueCondition();

            // TODO: Implement code to verify target
            Assert.Inconclusive("TODO: Implement code to verify target");
        }
 protected void VisitChildren()
 {
     Test         = TestCondition.AcceptVisitor(Visitor, ParentScope);
     IfTrue       = TrueCondition.AcceptVisitor(Visitor, ParentScope);
     IfFalse      = FalseCondition.AcceptVisitor(Visitor, ParentScope);
     InternalType = IfTrue.Type;
 }
Beispiel #3
0
        private void addPurchasingPolicyTrue()
        {
            bridge.Login(getStoreOwner1(), password);
            IBooleanExpression policy = new TrueCondition();
            string             json   = JsonHandler.SerializeObject(policy);

            policyId = bridge.addPurchasingPolicy(storeId, json);
            Assert.IsTrue(policyId >= 0);
        }
Beispiel #4
0
        public void AcceptTest()
        {
            TrueCondition target = new TrueCondition();

            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.");
        }
Beispiel #5
0
        public void Test___Method_Check___Value_False()
        {
            var testee = new TrueCondition {
                Value = new AnyVariable <bool>()
                {
                    Value = false
                }
            };

            Assert.IsFalse(testee.Check());
        }
Beispiel #6
0
        public static Policystatus removeSystemPolicy(User user, int policyid)
        {
            if (user is SystemAdmin)
            {
                IBooleanExpression temp = new TrueCondition();
                temp.id = policyid;

                if (SystemPolicies.Remove(temp))
                {
                    return(Policystatus.Success);
                }
            }
            return(Policystatus.UnauthorizedUser);
        }
        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;
    }
    /// <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;
    }
        //temporary method for retrieving app. menu elements
        public void IdentifyMenuElements()
        {
            AutomationElement appMenu = appWindow.FindFirstByXPath($"*[@AutomationId='menu']");

            FlaUI.Core.Conditions.TrueCondition condition = new TrueCondition();
            FlaUI.Core.Definitions.TreeScope    scope = FlaUI.Core.Definitions.TreeScope.Children;
            string menu = "Menu", menuItem = "", Item = "";
            int    idx = 0;

            AutomationElement[] cts = appMenu.FindAll(scope, condition);
            for (int x = 0; x < cts.LongCount(); x++)
            {
                if (cts[x].Properties.ControlType.ToString().Equals("MenuItem"))
                {
                    menuItem = cts[x].Name;
                    idx++;
                    AutomationElement[] mnsi = cts[x].FindAllChildren();
                    for (int h = 0; h < mnsi.LongCount(); h++)
                    {
                        AutomationElement menuItemObject = mnsi[h];
                        mnsi[h].Click();

                        AutomationElement[] subComps = cts[x].FindAllChildren();
                        for (int d = 0; d < subComps.LongCount(); d++)
                        {
                            Item = subComps[d].Name;

                            if (Item == null || Item.Equals("") || menuItem.Equals(Item))
                            {
                                continue;
                            }
                            SaveElementAttributes("SceneComposer", menu, menuItem, menuItemObject, Item, idx++, subComps[d].FindFirstChild());
                        }
                    }
                }
            }
            FileContent = objectDetails.ToString();
        }
Beispiel #13
0
        public void Test___Method_Check___Value_null()
        {
            var testee = new TrueCondition();

            Assert.IsTrue(testee.Check());
        }
Beispiel #14
0
    // public float radiusAlert = 40f;//radio para alertarse
    // public float radiusRun = 35f;//radio para huir


    void Start()
    {
        //INICIALIZAMOS LA DATA DEL EXTERIOR
        kineticsAgent      = agent.kineticsAgent;
        steeringAgent      = agent.steeringAgent;
        kineticsTrainer    = trainer.kineticsAgent;
        kineticsRival      = rival.kineticsAgent;
        sightSensor        = sightComponent.sensor;
        sightSensorPokemon = sightComponentPokemon.sensor;
        soundSensor        = soundComponent.sensor;



        //Piedras
        stones = GameObject.FindGameObjectsWithTag("Stone");
        List <GameObject> stonesList = new List <GameObject>(stones);


        //Inicializamos grafo y A*
        graph = graphComponent.graph;
        aStar = new PathFindAStar(graph, null, null, null, walkable);

        //Inicializamos seek
        seek = new Seek(kineticsAgent, kineticsAgent, maxAccel);

        //Inicializamos lookwehereyougoing
        look = new LookWhereYouAreGoing(kineticsAgent);

        //Obstaculos
        GameObject[]    obstacles     = GameObject.FindGameObjectsWithTag("Obstacle");
        obstacle_data[] obstaclesData = new obstacle_data[obstacles.Length];

        for (int k = 0; k < obstacles.Length; k++)
        {
            obstaclesData[k] = obstacles[k].GetComponent <obstacle_data>();
        }

        //Puntos estrategicos
        strategicPoints = pointsComponent.coverNodes;



        //COMENZAMOS A CONSTRUIR LA MAQUINA DE ESTADOS

        //1. ACCIONES:

        //acciones relacionadas a astar
        FollowPathOfPoints        followPath       = new FollowPathOfPoints(steeringAgent, seek, null, false);
        UpdateFollowPathWithAstar updateFollow     = new UpdateFollowPathWithAstar(followPath, aStar, obstaclesData);
        UpdateAstarBestCoverPoint updateAstarCover = new UpdateAstarBestCoverPoint(strategicPoints, transform, new Transform[] { kineticsRival.transform, kineticsTrainer.transform }, obstaclesData, graph, aStar, walkable);
        UpdateAStarSeenStone      updateAstarStone = new UpdateAStarSeenStone(sightSensor, aStar, graph, transform, walkable);
        //acciones de manejo de giros
        SetAngularSpeed setDefaultRotation = new SetAngularSpeed(kineticsAgent, 10f);
        SetAngularSpeed setZeroRotation    = new SetAngularSpeed(kineticsAgent, 0f);
        StopMoving      stop       = new StopMoving(kineticsAgent, steeringAgent);
        LookWhereGoing  lookAction = new LookWhereGoing(look, steeringAgent);
        //acciones de manejo de srpites
        ShowDefaultSprite defaultSprite = new ShowDefaultSprite(pokemonData);
        RunSprite         showRunSprite = new RunSprite(pokemonData);
        Evolve2           evolve;
        ShowIcon          showExclamation    = new ShowIcon(this.gameObject, "Exclamation");
        DisableIcon       disableExclamation = new DisableIcon(this.gameObject, "Exclamation");
        ShowIcon          showSweat          = new ShowIcon(this.gameObject, "Sweat");
        DisableIcon       disableSweat       = new DisableIcon(this.gameObject, "Sweat");
        //acciones de asistencia
        ResetSensor     resetSight        = new ResetSensor(sightSensor);
        ResetSensor     resetSightPokemon = new ResetSensor(sightSensorPokemon);
        ResetSensor     resetSound        = new ResetSensor(soundSensor);
        ResetSensorList resetSensors      = new ResetSensorList(new List <ResetSensor>()
        {
            resetSight, resetSound, resetSightPokemon
        });
        //acciones de tiempo
        SetTimer setAlertTime;
        //acciones que modifican la maquina de estados misma
        RemoveStateTransition removeTouchStone;
        RemoveStateTransition removeSawStone;
        RemoveStateTransition removeSawStone2;
        RemoveAction          removeDefaultSpriteAction;
        RemoveAction          removeRunSpriteAction;
        RemoveAction          removeRunSpriteAction2;



        //2. ESTADOS:

        List <Action> entryActions; //aqui iremos guardanndo todas las acciondes de entrada
        List <Action> exitActions;  //aqui iremos guardanndo todas las acciones de salida
        List <Action> actions;      //aqui guardaremos todas las acciones intermedias

        //2.a estado para esperar sin hacer nada
        //durante este estado eevee estara quieto hasta que algun humano lo haga reaccionar
        entryActions = new List <Action>()
        {
            stop, defaultSprite, setZeroRotation, resetSensors
        };                                                                                     //al entrar al estado debemos parar y sentarnos
        removeDefaultSpriteAction = new RemoveAction(defaultSprite, entryActions);
        actions = new List <Action>()
        {
        };                            //hacer guardia girando
        exitActions = new List <Action>()
        {
        };

        State wait = new State(actions, entryActions, exitActions);


        //2.b estado para sorprenderse
        //durante este estado eevee dara vueltas en alterta angustiado porque escucho algo, este estado durara solo cierto tiempo
        entryActions = new List <Action>()
        {
            showExclamation, setDefaultRotation
        };                                                                      //al entrar al estado debemos sorprendernos
        actions = new List <Action>()
        {
        };
        exitActions = new List <Action>()
        {
            disableExclamation, setZeroRotation
        };                                                                    //al salir dejamos de sorprendernos

        State alert = new State(actions, entryActions, exitActions);

        //2.c estado para perseguir piedra
        //durante este estado eevee se concentrara unicamente en buscar las piedra que vio
        entryActions = new List <Action>()
        {
            updateAstarStone, updateFollow, showExclamation, showRunSprite
        };                                                                                                 //al entrar al estado debemos actualizar el a* y luego el camino
        removeRunSpriteAction2 = new RemoveAction(showRunSprite, entryActions);
        actions = new List <Action>()
        {
            followPath, lookAction
        };                                                   //durante la accion seguimos el camino
        exitActions = new List <Action>()
        {
            disableExclamation
        };                                                    //al salir no hacemos nada

        State followStone = new State(actions, entryActions, exitActions);

        //2.d estado para perseguir punto de encuentro
        //durante este estado eevee buscara donde esconderse, puede verse interrumpido si accidentalmente toca una piedra o se comprometio su escondite
        entryActions = new List <Action>()
        {
            updateAstarCover, updateFollow, showSweat, showRunSprite, resetSensors
        };                                                                                                         //al entrar al estado debemos actualizar el a* y luego el camino
        removeRunSpriteAction = new RemoveAction(showRunSprite, entryActions);
        actions = new List <Action>()
        {
            followPath, lookAction
        };                                                   //durante la accion seguimos el camino
        exitActions = new List <Action>()
        {
            disableSweat
        };                                              //al salir no hacemos nada

        State followCoverPoint = new State(actions, entryActions, exitActions);

        //2.extra dummy states
        //estos estados son de relleno para facilitar la activacion de ciertas acciones en le orden adecuado
        entryActions = new List <Action>(); //al entrar al estado debemos parar y sentarnos
        actions      = new List <Action>(); //hacer guardia girando
        exitActions  = new List <Action>(); //al salir no hacemos nada

        State evolveState1 = new State(actions, entryActions, exitActions);
        State evolveState2 = new State(actions, entryActions, exitActions);



        //3. CONDICIONES:

        SawSomething       sawStone            = new SawSomething(sightSensor, "Stone");               //si vemos una piedra evolutiva
        SawSomething       sawHuman            = new SawSomething(sightSensor, "Human");               //si vemos una persona
        HeardSomething     heardHumanClose     = new HeardSomething(soundSensor, "Human", 0f);         //si escuchamos a un humano cerca
        HeardSomething     heardHumanVeryClose = new HeardSomething(soundSensor, "Human", 5f);         //si escuchamos a un  humanos muy cerca
        TouchedGameObjects touchedStone        = new TouchedGameObjects(stonesList, transform, "Sun"); //si tocamos una piedra evolutiva

        evolve = new Evolve2(pokemonData, touchedStone, updateAstarCover, aStar);
        FollowArrived       arrived        = new FollowArrived(followPath, transform);                      //si llegamos al objetivo de follow
        PokemonInCoverPoint otherInMyCover = new PokemonInCoverPoint(aStar, sightSensorPokemon, transform); //si vemos que un pokemon se metio en nuestro escondite

        TimeOut alertTimeOut = new TimeOut(5f);

        setAlertTime = new SetTimer(alertTimeOut);
        TrueCondition alwaysTrue = new TrueCondition();


        //4. TRANSICIONES:

        List <Action> transitionsActions;
        List <Action> noActions = new List <Action>();

        transitionsActions = new List <Action>()
        {
            setAlertTime
        };
        Transition heardCloseHuman     = new Transition(heardHumanClose, transitionsActions, alert);
        Transition seemsSafe           = new Transition(alertTimeOut, noActions, wait);
        Transition heardVeryCloseHuman = new Transition(heardHumanVeryClose, noActions, followCoverPoint);

        transitionsActions = new List <Action>()
        {
        };
        Transition sawAhuman        = new Transition(sawHuman, transitionsActions, followCoverPoint);
        Transition sawAstone        = new Transition(sawStone, transitionsActions, followStone);
        Transition pokemonInMyCover = new Transition(otherInMyCover, transitionsActions, followCoverPoint);

        //transiciones dummy
        transitionsActions = new List <Action>()
        {
            evolve
        };
        Transition evolving1 = new Transition(alwaysTrue, transitionsActions, followCoverPoint);
        Transition evolving2 = new Transition(alwaysTrue, transitionsActions, wait);


        transitionsActions = new List <Action>()
        {
            evolve, removeDefaultSpriteAction, removeRunSpriteAction, removeRunSpriteAction2
        };
        Transition touchStone1 = new Transition(touchedStone, transitionsActions, evolveState1);
        Transition touchStone2 = new Transition(touchedStone, transitionsActions, evolveState2);

        //si evolucionamos debemos quitar las transiciones relacionadas a las stones
        removeSawStone   = new RemoveStateTransition(sawAstone, followCoverPoint);
        removeSawStone2  = new RemoveStateTransition(sawAstone, alert);
        removeTouchStone = new RemoveStateTransition(touchStone1, followCoverPoint);
        transitionsActions.Add(removeSawStone);
        transitionsActions.Add(removeSawStone2);
        transitionsActions.Add(removeTouchStone);

        Transition arrivedFollowEnd = new Transition(arrived, noActions, wait);

        //4.1 AGREGAMOS TRANSICIONES A ESTADOS

        List <Transition> transitions;

        transitions = new List <Transition>()
        {
            sawAhuman, heardCloseHuman
        };
        wait.transitions = transitions;

        transitions = new List <Transition>()
        {
            sawAhuman, sawAstone, heardVeryCloseHuman, seemsSafe
        };
        alert.transitions = transitions;

        transitions = new List <Transition>()
        {
            evolving1
        };
        evolveState1.transitions = transitions;

        transitions = new List <Transition>()
        {
            evolving2
        };
        evolveState2.transitions = transitions;


        transitions = new List <Transition>()
        {
            touchStone1, sawAstone, pokemonInMyCover, arrivedFollowEnd, sawAhuman
        };
        followCoverPoint.transitions = transitions;

        transitions = new List <Transition>()
        {
            touchStone2, arrivedFollowEnd, pokemonInMyCover
        };
        followStone.transitions = transitions;



        //5 MAQUINA DE ESTADOS
        State[] states = new State[] { wait, alert, followCoverPoint, followStone, evolveState1, evolveState2 };
        eeveeMachine = new StateMachine(states, wait);
    }
        public void TrueevaluateTest()
        {
            TrueCondition trueCondition = new TrueCondition();

            Assert.IsTrue(trueCondition.evaluate(list, user));
        }
Beispiel #16
0
 /// <summary>
 /// Visits the true.
 /// </summary>
 /// <remarks>
 /// Generate a 1, a true value
 /// </remarks>
 /// <param name="t">The t.</param>
 public void VisitTrue(TrueCondition trueObject)
 {
     Instructions.Add(Worker.Create(OpCodes.Ldc_I4_1));
 }