public void EntOneProp_KString_VInt()
        {
            EtagairCore core = Common.CreateCore(RepositConfig);

            // create an entity template to instantiate
            EntityTempl templComputer = core.EditorTempl.CreateEntityTempl("TemplComputer");

            // add property
            core.EditorTempl.CreatePropTempl(templComputer, "Count", 25);

            //====Instanciate the template, create an entity, under the root folder
            EntityTemplToInst templToInst = core.ProcessTempl.CreateEntity(templComputer);

            //====check that the execution finishes with success
            Assert.AreEqual(TemplToInstState.Success, templToInst.State, "the state should be sucess");
            Assert.AreEqual(TemplToInstStep.Ends, templToInst.NextStep, "the next step should be ends");

            // check, get the key property: Count
            PropertyBase propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Count", false);
            Property     prop     = propBase as Property;

            //----check the prop key, is: Count
            PropertyKeyString propKeyString = prop.Key as PropertyKeyString;

            Assert.IsNotNull(propKeyString, "the prop key string Type should exists");
            Assert.AreEqual("Count", propKeyString.Key, "the key should be Count");

            // check the prop value
            ValInt propValueInt = prop.Value as ValInt;

            Assert.IsNotNull(propValueInt, "the prop key int Count should exists");
            Assert.AreEqual(25, propValueInt.Value, "the value should be 12.0");
        }
示例#2
0
    /// <summary>
    /// Callback for when the input is changed.
    /// </summary>
    public void OnTextChange()
    {
        Val vb = null;

        if (this.EV.val.ty == Val.Type.Float)
        {
            if (float.TryParse(this.input.text, out float f) == true)
            {
                vb = new ValFloat(f);
            }
        }
        else
        {
            if (int.TryParse(this.input.text, out int i) == true)
            {
                vb = new ValInt(i);
            }
        }

        if (vb != null)
        {
            this.EV.val.SetValue(this.EV.Clamp(vb));
            this.Mgr.NotifyActorModified(this.actor, this.EV.name);
        }
        this.OnUpdateValue();
    }
示例#3
0
        /// <summary>
        /// Create a property to an object: key - value,
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="tcKey"></param>
        /// <param name="tcValue"></param>
        /// <returns></returns>
        public Property CreateProperty(Entity entity, PropertyGroup propertyParent, TextCode tcKey, int value)
        {
            // create the property value
            ValInt valInt = new ValInt();

            valInt.Value = value;

            return(CreateProperty(entity, propertyParent, tcKey, valInt));
        }
示例#4
0
        public void CreateEntity_Prop_KeyString_ValInt()
        {
            EtagairCore core = Common.CreateCore(RepositConfig);

            // create an ent
            Entity toshibaCoreI7 = core.Editor.CreateEntity();

            // Add a property to an object: key - value
            Property propName = core.Editor.CreateProperty(toshibaCoreI7, "Year", 2019);

            // check the property key (type and value)
            PropertyKeyString propKeyString = propName.Key as PropertyKeyString;

            Assert.IsNotNull(propKeyString, "the key should be a string");
            Assert.AreEqual("Year", propKeyString.Key, "the key should be 'Year'");

            // check the property value (type and value)
            ValInt propValueInt = propName.Value as ValInt;

            Assert.IsNotNull(propValueInt, "the value should be an int");
            Assert.AreEqual(2019, propValueInt.Value, "the key should be an int");
        }
示例#5
0
        public void CreateEntity_Prop_KeyTextCode_ValInt()
        {
            EtagairCore core = Common.CreateCore(RepositConfig);

            TextCode tcName = core.Editor.CreateTextCode("Level");

            // create an ent
            Entity toshibaCoreI7 = core.Editor.CreateEntity();

            // Add a property to an object: key - value
            Property propName = core.Editor.CreateProperty(toshibaCoreI7, tcName, 15);

            // check the property key (type and value)
            PropertyKeyTextCode propKeyTextCode = propName.Key as PropertyKeyTextCode;

            Assert.IsNotNull(propKeyTextCode, "the key should be a TextCode");
            Assert.AreEqual(tcName.Id, propKeyTextCode.TextCodeId, "the key should be 'Name'");

            // check the property value (type and value)
            ValInt propValueInt = propName.Value as ValInt;

            Assert.IsNotNull(propValueInt, "the value should be an int");
            Assert.AreEqual(15, propValueInt.Value, "the value should be 15");
        }
示例#6
0
 public override int GetHashCode()
 {
     return(DateTime.GetHashCode() ^ ValInt.GetHashCode() ^ (ValString == null ? 0 : ValString.GetHashCode()));
 }