Example #1
0
        public void EntityTestPropertyTypeUpdatesWithOperator()
        {
            //initial test
            string strKey            = "STR";
            string expression        = $"{BaseEntity.Key}{LConstants.PROP_OP}{strKey}";
            double expected          = BaseEntity.GetProperty(strKey).Value;
            MeNode tree              = TreeConverter.Build(expression, Engine);
            MeNode partiallyResolved = TreeResolver.ResolveGivenOperations(tree, new string[1] {
                LConstants.PROP_OP
            });

            Assert.AreEqual(expected, partiallyResolved.Value.ToDouble());

            //apply a status that modifies the value
            string expression2 = $"{LConstants.ADD_MOD_F}(STR,$0)";

            MeNode[]       statuses = Engine.GetSanitizer().SplitAndConvert(expression2);
            StatusTemplate test     = new StatusTemplate(statuses)
            {
                Interval = TreeConverter.Build("0", Engine)
            };

            test.Key = "TEST_STATUS_KEY311";
            double[] values = { 10 };

            BaseEntity.ApplyStatus(test, BaseEntity, 10, values);
            BaseEntity.Update();

            //test again
            expected = BaseEntity.GetProperty(strKey).Value;
            Assert.AreEqual(expected, partiallyResolved.Value.ToDouble());
            BaseEntity.Cleanse();
        }