public ActionResult <String> GetEvaluation(int id, String color)
 {
     try
     {
         var indicator = indicatorLogic.GetById(id);
         if (indicator == null)
         {
             return(NotFound());
         }
         NodeLogic     nl         = new NodeLogic(null);
         List <String> evaluation = new List <string>();
         evaluation.Add(nl.GetText(indicator.Green));
         evaluation.Add(nl.Evaluate(indicator.Green) + "");
         evaluation.Add(nl.GetText(indicator.Yellow));
         evaluation.Add(nl.Evaluate(indicator.Yellow) + "");
         evaluation.Add(nl.GetText(indicator.Red));
         evaluation.Add(nl.Evaluate(indicator.Red) + "");
         return(Ok(evaluation));
     }
     catch (NullException) { return(BadRequest("No es posible obtener un indicador nulo")); }
     catch (NotFoundException) { return(BadRequest("No fue posible obtener ese indicador")); }
     catch (NullReferenceException) { return(BadRequest("No es posible obtener un indicador nulo")); }
     catch (NotValidException) { return(BadRequest("No es posible obtener un indicador no válido")); }
     catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); }
     catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); }
 }
    // Update is called once per frame
    void Update()
    {
        for (int i = 0; i < nodeManager.nodeList.Count; i++)
        {
            if (nodeManager.nodeList[i].resourceAmount <= 0)
            {
                //Create a clone of a base resource node
                GameObject newNode = (GameObject)Instantiate(Resources.Load("Prefabs/BaseNodePrefab"));

                //copy over the perameters of the old node
                newNode.tag = nodeManager.nodeList[i].tag;
                newNode.GetComponent <Renderer>().material = nodeManager.nodeList[i].GetComponent <Renderer>().material;
                newNode.transform.position = nodeManager.nodeList[i].transform.position;
                newNode.name = nodeManager.nodeList[i].name;
                newNode.GetComponent <NodeLogic>().resourceAmount = Random.Range(50.0f, 120.0f);

                //generate a randomised co-ordinate to generate the new node
                Vector3 gameAreaMin = GameObject.Find("PlayArea").GetComponent <BoxCollider>().bounds.min;
                Vector3 gameAreaMax = GameObject.Find("PlayArea").GetComponent <BoxCollider>().bounds.max;

                Vector3 generatePosition;
                generatePosition.x = Random.Range(gameAreaMin.x, gameAreaMax.x);
                generatePosition.z = Random.Range(gameAreaMin.z, gameAreaMax.z);
                generatePosition.y = nodeManager.nodeList[i].transform.position.y;

                newNode.transform.position = generatePosition;

                //get rid of the old node
                NodeLogic toDelete = nodeManager.nodeList[i];
                nodeManager.nodeList.RemoveAt(i);

                toDelete.Delete();
            }
        }
    }
Пример #3
0
        public void NodeLogic_NodeIdInvalidGuid_ArgumentOutOfRangeException()
        {
            NodeLogic nodeLogic = new NodeLogic(null, null, null, null, null, null, null);

            string id = "zzz";

            nodeLogic.Get(id);
        }
Пример #4
0
        public void NodeLogic_Get_NullId_ArgumentNullException()
        {
            NodeLogic nodeLogic = new NodeLogic(null, null, null, null, null, null, null);

            string id = null;

            nodeLogic.Get(id);
        }
Пример #5
0
        public void NodeLogic_ConfigurationRepository_ReturnsNull()
        {
            string id     = "27904fa2-fdde-4bde-942a-11628a2a48e5";
            Guid   idGuid = Guid.Parse(id);

            Mock <IConfigurationRepository> configRepo = new Mock <IConfigurationRepository>();

            configRepo.Setup(m => m.Get <NodeDetails>(It.IsAny <Guid>())).Returns((NodeDetails)null);

            NodeLogic nodeLogic = new NodeLogic(configRepo.Object, null, null, null, null, null, null);

            nodeLogic.Get(id);
        }
        public void CompareStrings()
        {
            var Left = new Operator
            {
                Text = "operador",
            };
            var Right = new Operator
            {
                Text = "operador",
            };
            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.IsTrue(nodeLogic.Compare(Left, Right, "="));
        }
        public void CompareBoolOperator()
        {
            var area = new Area {
                DataSource = "Server=localhost\\SQLEXPRESS;Database=DataSourceDB;Trusted_Connection=True;",
            };
            var Left1 = new Operator
            {
                Type = 3,
                Text = "SELECT UserId FROM ACCOUNT WHERE UserId = 'ALFKI'",
                Area = 1,
            };
            var Right1 = new Operator
            {
                Type = 1,
                Text = "ALFKI",
            };

            var binaryLeft = new BinaryOperator
            {
                Type  = 4,
                Left  = Left1,
                Right = Right1,
                Sign  = "=",
            };

            var Left2 = new Operator
            {
                Type = 3,
                Text = "SELECT count(*) FROM ACCOUNT",
                Area = 1,
            };
            var Right2 = new Operator
            {
                Type = 2,
                Text = "5",
            };
            var binaryRight = new BinaryOperator
            {
                Type  = 4,
                Left  = Left2,
                Right = Right2,
                Sign  = ">",
            };

            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.IsTrue(nodeLogic.Compare(binaryLeft, binaryRight, "AND"));
        }
        public void CompareEqualsNumeric()
        {
            var Left = new Operator
            {
                Type = 2,
                Text = "123",
            };
            var Right = new Operator
            {
                Type = 2,
                Text = "123",
            };
            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.IsTrue(nodeLogic.Compare(Left, Right, "="));
        }
        public void CompareBiggerNumeric()
        {
            var Left = new Operator
            {
                Type = 2,
                Text = "40000",
            };
            var Right = new Operator
            {
                Type = 2,
                Text = "123",
            };
            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.AreEqual(nodeLogic.Evaluate(Right)[1], "123");
            Assert.IsTrue(nodeLogic.CompareBigger(Left, Right));
        }
Пример #10
0
        public void CompareSQLNumeric()
        {
            var area = new Area {
                DataSource = "Server=localhost\\SQLEXPRESS;Database=DataSourceDB;Trusted_Connection=True;",
            };
            var Left = new Operator
            {
                Type = 3,
                Text = "SELECT count(*) FROM ACCOUNT",
                Area = 1,
            };
            var Right = new Operator
            {
                Type = 2,
                Text = "5",
            };
            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.IsTrue(nodeLogic.Compare(Left, Right, ">"));
        }
Пример #11
0
        public void CompareSQLString()
        {
            var area = new Area {
                DataSource = "Server=localhost\\SQLEXPRESS;Database=DataSourceDB;Trusted_Connection=True;",
            };
            var Left = new Operator
            {
                Type = 3,
                Text = "SELECT UserId FROM ACCOUNT WHERE UserId = 'ALFKI'",
                Area = 1,
            };
            var Right = new Operator
            {
                Type = 1,
                Text = "ALFKI",
            };
            NodeLogic nodeLogic = new NodeLogic(null);

            Assert.IsTrue(nodeLogic.Compare(Left, Right, "="));
        }
Пример #12
0
 public ActionResult <int> GetIndicators(int id, String color)
 {
     try
     {
         var user = userLogic.GetUserByID(id);
         List <Indicator> indicators = userLogic.GetAllIndicators(user);
         List <Indicator> toReturn   = new List <Indicator>();
         NodeLogic        nodeLogic  = new NodeLogic(null);
         foreach (Indicator indicator in indicators)
         {
             if (color.ToLowerInvariant() == "green" && nodeLogic.Evaluate(indicator.Green))
             {
                 toReturn.Add(indicator);
             }
             if (color.ToLowerInvariant() == "red" && nodeLogic.Evaluate(indicator.Red))
             {
                 toReturn.Add(indicator);
             }
             if (color.ToLowerInvariant() == "yellow" && nodeLogic.Evaluate(indicator.Yellow))
             {
                 toReturn.Add(indicator);
             }
             if (color.ToLowerInvariant() == "all")
             {
                 toReturn.Add(indicator);
             }
         }
         return(Ok(toReturn.Count));
     }
     catch (NullException) { return(BadRequest("No es posible obtener un usuario nulo")); }
     catch (NotFoundException) { return(BadRequest("No fue posible obtener ese usuario")); }
     catch (NullReferenceException) { return(BadRequest("No es posible obtener un usuario nulo")); }
     catch (NotValidException) { return(BadRequest("No es posible obtener un usuario no válido")); }
     catch (DataBaseLogicException) { return(BadRequest("Error en la conexión con la base de datos")); }
     catch (InvalidOperationLogicException) { return(BadRequest("Error en el sistema")); }
 }
Пример #13
0
 public NodeController(IConfigurationRepository configurationRepository, NodeLogic nodeLogic)
 {
     this.nodeLogic = nodeLogic;
     this.configurationRepository = configurationRepository;
     this.http = new HttpResponseHandler(this);
 }
 //Call this to add a node to the list
 public void addToList(NodeLogic node)
 {
     nodeList.Add(node);
 }