/// <summary>
        /// Check the consistency of the property template.
        /// Return the number of problems.
        /// cases:
        ///   -key prop must exists (not null),
        ///   -a null prop value -> a rule PropValueSetOnInstance must exists.
        /// </summary>
        /// <param name="entityTempl"></param>
        /// <param name="propTemplBase"></param>
        /// <returns></returns>
        private int CheckConsistencyPropTempl(EntityTempl entityTempl, PropTemplBase propTemplBase, List <PropTemplRuleBase> listRuleToExec)
        {
            int pbCount = 0;

            // is the property a group?
            PropGroupTempl propGroupTempl = propTemplBase as PropGroupTempl;

            if (propGroupTempl != null)
            {
                // get rules
                // TODO:  strategie instancier child: Single, Several,...

                // check properties childs
                foreach (PropTemplBase propTemplChild in propGroupTempl.ListProperty)
                {
                    pbCount += CheckConsistencyPropTempl(entityTempl, propTemplChild, listRuleToExec);
                }
                return(pbCount);
            }

            // is the property a final one?
            PropTempl propTempl = propTemplBase as PropTempl;

            if (propTempl != null)
            {
                return(CheckConsistencyPropTempl(entityTempl, propTempl, listRuleToExec));
            }

            throw new Exception("PropTempl type not implemented!");
        }
Пример #2
0
        /// <summary>
        /// Add a rule to a property template.
        /// </summary>
        /// <param name="propTempl"></param>
        /// <param name="rule"></param>
        /// <returns></returns>
        public bool AddPropTemplRule(EntityTempl entityTempl, PropTempl propTempl, PropTemplRuleBase rule)
        {
            // do some checks
            // TODO:

            // the propTempl shouln't have the same rule type
            if (propTempl.ListRule.Find(r => r.Type == rule.Type) != null)
            {
                return(false);
            }

            rule.EntityTemplId = entityTempl.Id;

            rule.PropKeyTempl = propTempl.Key;

            // find the property group parent of the prop
            //PropGroupTempl propGroupTemplParent = FindPropGroupTemplParent(entityTempl, propTempl);
            //rule.PropGroupTemplId = propGroupTemplParent.Id;
            rule.PropGroupTemplId = propTempl.PropGroupTemplParentId;

            propTempl.AddRule(rule);

            // save the entity modification
            return(_reposit.Builder.UpdateEntityTempl(entityTempl));
        }
        public void Ent_PropGroup_Prop_KString_VString()
        {
            EtagairCore core = Common.CreateCoreInMemory();

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

            // create the group Core
            PropGroupTempl propGroupTemplCore = core.EditorTempl.CreatePropGroupTempl(templComputer, "Core");

            // under the propGroup Core, create the prop Type=Intel
            PropTempl propTemplType = core.EditorTempl.CreatePropTempl(templComputer, propGroupTemplCore, "Type", "Intel");

            //====Instantiate
            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 the creation

            //----check the prop group: Core
            PropertyBase  propBase  = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Core", false);
            PropertyGroup propGroup = propBase as PropertyGroup;

            Assert.IsNotNull(propGroup, "the propgroup Core should exists");

            // Check the prop group key
            PropertyKeyString propGroupKey = propGroup.Key as PropertyKeyString;

            Assert.IsNotNull(propGroupKey, "the propgroup key Core should exists");
            Assert.AreEqual("Core", propGroupKey.Key, "the key should be Core");

            //----check the property child: Type=Computer
            propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, propGroup, "Type", false);
            Property prop = propBase as Property;

            Assert.IsNotNull(prop, "the prop child Type should exists");

            // find the prop Intel (inside the group Core) from the root property
            PropertyBase propBaseTypeIntel = core.Searcher.FindPropertyByKey(templToInst.Entity, "Type", true);
            Property     propTypeIntel     = propBaseTypeIntel as Property;

            Assert.IsNotNull(propTypeIntel, "the prop child Type should exists (find from the root)");

            // check the prop key: Type, find the prop from the parent
            PropertyKeyString propKeyString = prop.Key as PropertyKeyString;

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

            // check the prop value
            //PropertyValueString propValueString = prop.Value as PropertyValueString;
            ValString propValueString = prop.Value as ValString;

            Assert.IsNotNull(propValueString, "the prop key string Type should exists");
            Assert.AreEqual("Intel", propValueString.Value, "the value should be Intel");
        }
Пример #4
0
        /// <summary>
        /// Templ Entity, has a rule the property value: will be set on entity instantiation.
        ///
        /// EntTempl TemplComputer
        ///    P: K="Name", V=RULE:ToSet
        ///
        /// The creation of the entity need to provide the property value text.
        /// Ent
        ///    P: K="Name", V="Toshiba"
        ///
        /// </summary>
        public void EntityTemplate_Rule_PropValToSet()
        {
            EtagairEngine engine = CreateEngine();

            Console.WriteLine("Create an entity template with a rule.");


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

            // create a property template without the value: will be created on the instantiation
            PropTempl propTempl = engine.EditorTempl.CreatePropTemplValueStringNull(templComputer, "Name");

            // Add Rule: add property, V=RULE:Toset, type= TextCode: to be set on instanciation
            PropTemplRuleValueToSet rule = new PropTemplRuleValueToSet();

            rule.ValueType = PropValueType.String;
            engine.EditorTempl.AddPropTemplRule(templComputer, propTempl, rule);

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

            // the state should be InProgress/NeedAction
            Console.WriteLine("\n1. Create entity:");
            Console.WriteLine("  State: " + templToInst.State.ToString());
            Console.WriteLine("  NextStep: " + templToInst.NextStep.ToString());

            // provide an action to the rule (to execute it automatically): Property value set on instantiation
            PropTemplRuleActionValueToSet action = new PropTemplRuleActionValueToSet();

            action.SetRule(rule);
            action.SetValueString("Toshiba");

            // adds actions to rules and create the entity
            engine.ProcessTempl.AddActionsToCreateEntity(templToInst, action);

            // the state should be InProgress/NeedAction
            Console.WriteLine("\n2. Add Action to the rule: PropValue SetTo='Toshiba'");
            Console.WriteLine("  State: " + templToInst.State.ToString());
            // the nextStep should be: Ends
            Console.WriteLine("  NextStep: " + templToInst.NextStep.ToString());

            // create the entity, use action
            engine.ProcessTempl.CompleteCreateEntity(templToInst);

            // the state should be InProgress/NeedAction
            Console.WriteLine("\n3. Complete the creation:");
            Console.WriteLine("  State: " + templToInst.State.ToString());
            // the nextStep should be: Ends
            Console.WriteLine("  NextStep: " + templToInst.NextStep.ToString());

            // displays the entity id
            Console.WriteLine("\n-----Created entity id: " + templToInst.Entity.Id);
            DisplayEntity(engine, templToInst.Entity, 0, false);
        }
        /// <summary>
        /// Instantiate all properties childs of the group, from the template.
        /// </summary>
        /// <param name="entityTempl"></param>
        /// <param name="propToProcess"></param>
        /// <param name="entity"></param>
        /// <param name="property"></param>
        /// <param name="listRuleWithoutAction"></param>
        /// <returns></returns>
        public bool CreateAllPropGroupChildsFromTempl(EntityTempl entityTempl, PropGroupTempl propGroupTempl, Entity entity, PropertyGroup propGroupParent, List <PropTemplRuleActionBase> listAction, out List <PropTemplRuleBase> listRuleWithoutAction)
        {
            // get the rules of the group properties
            // propGroupTemplToProcess.ListRule
            // TODO: strategie??  OneOf, Several,...

            listRuleWithoutAction = new List <PropTemplRuleBase>();

            List <PropGroupTempl> listPropGroupTemplChilds = new List <PropGroupTempl>();

            // scan property childs of the template
            foreach (PropTemplBase propTemplBase in propGroupTempl.ListProperty)
            {
                // is it a group templ?
                PropGroupTempl propGroupTemplChild = propTemplBase as PropGroupTempl;
                if (propGroupTemplChild != null)
                {
                    // saved, to be process after all direct finals properties
                    listPropGroupTemplChilds.Add(propGroupTemplChild);
                    continue;
                }

                // is it propTempl (final)?
                PropTempl propTemplChild = propTemplBase as PropTempl;
                if (propTemplChild != null)
                {
                    CreatePropFromTempl(propTemplChild, propGroupParent, listAction, listRuleWithoutAction);
                }
            }

            // there are rules without action, need external actions, stops here
            if (listRuleWithoutAction.Count > 0)
            {
                return(true);
            }

            // now process all prop group templ childs
            foreach (PropGroupTempl propGroupTemplChild in listPropGroupTemplChilds)
            {
                PropertyGroup propGroupChild;

                // create first the propGroup from the template, is empty (no child)
                CreatePropGroupFromTempl(propGroupTemplChild, propGroupParent, listAction, listRuleWithoutAction, out propGroupChild);

                // save/update the entity, will create missing id
                _reposit.Builder.UpdateEntity(entity);

                // then create the prop childs of the group, from the template
                List <PropTemplRuleBase> listRuleWithoutActionChilds;
                CreateAllPropGroupChildsFromTempl(entityTempl, propGroupTemplChild, entity, propGroupChild, listAction, out listRuleWithoutActionChilds);
                listRuleWithoutAction.AddRange(listRuleWithoutActionChilds);
            }

            return(true);
        }
Пример #6
0
        /// <summary>
        /// Find a property by the key "raw" string (can be a textCode).
        /// in direct childs.
        /// (not recursivly).
        /// </summary>
        /// <param name="entityTempl"></param>
        /// <param name="key"></param>
        /// <returns></returns>
        public PropTemplBase FindPropTemplBaseByKey(EntityTempl entityTempl, PropGroupTempl propertyTemplParent, string key)
        {
            if (entityTempl == null)
            {
                return(null);
            }
            if (propertyTemplParent == null)
            {
                return(null);
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                return(null);
            }

            // load the textCode of the key, if exists
            TextCode tcKey = _reposit.Finder.FindTextCodeByCode(key);

            // the key can be a string or a textCode
            foreach (var propertyBase in propertyTemplParent.ListProperty)
            {
                // is it a final property?
                PropTempl property = propertyBase as PropTempl;
                if (property != null)
                {
                    // is the property key a textCode?
                    if (IsKeyMatchProperty(property, key, tcKey))
                    {
                        return(property);
                    }

                    // next property
                    continue;
                }

                // is it a group property?
                PropGroupTempl propertyGroup = propertyBase as PropGroupTempl;
                if (propertyGroup != null)
                {
                    // is the property key a textCode?
                    if (IsKeyMatchProperty(propertyGroup, key, tcKey))
                    {
                        return(propertyGroup);
                    }

                    // next property
                    continue;
                }
            }

            // not found
            return(null);
        }
Пример #7
0
        //====very generic (low-level) method

        public PropTempl CreatePropTempl(EntityTempl entityTempl, PropGroupTempl propGroupTemplParent, PropKeyTemplBase propKey, PropValueTempl propValue)
        {
            // check the entity parent
            if (entityTempl == null)
            {
                return(null);
            }

            if (propGroupTemplParent == null)
            {
                propGroupTemplParent = entityTempl.PropertyRoot;
            }

            if (propKey == null)
            {
                return(null);
            }

            string propKeyString = GetPropKeyTemplString(propKey);

            // check the key, not used by an existing property
            if (FindPropTemplBaseByKey(entityTempl, propGroupTemplParent, propKeyString) != null)
            {
                return(null);
            }

            // create the property, set the key and the value
            PropTempl propertyTempl = new PropTempl();

            propertyTempl.PropGroupTemplParentId = propGroupTemplParent.Id;

            propertyTempl.SetKeyValue(propKey, propValue);

            // add the property under the root properties
            entityTempl.AddProperty(propGroupTemplParent, propertyTempl);

            // save the entity modification
            if (!_reposit.Builder.UpdateEntityTempl(entityTempl))
            {
                return(null);
            }

            return(propertyTempl);
        }
        //public IValue CreatePropValueFromTempl(IValue propTemplValue)
        //{
        //    ici();
        //    PropValueTemplString propValueTemplString = propTemplValue as PropValueTemplString;
        //    if (propValueTemplString != null)
        //    {
        //        PropertyValueString propValueString = new PropertyValueString();
        //        propValueString.Value = propValueTemplString.Value;
        //        return propValueString;
        //    }

        //    PropValueTemplTextCode propValueTemplTextCode = propTemplValue as PropValueTemplTextCode;
        //    if (propValueTemplTextCode != null)
        //    {
        //        PropertyValueTextCode propValueTextCode = new PropertyValueTextCode();
        //        propValueTextCode.TextCodeId = propValueTemplTextCode.TextCodeId;
        //        return propValueTextCode;
        //    }

        //    throw new Exception("property Value type not yet implemented!");
        //}

        #region Private methods

        /// <summary>
        /// 1- Create the key by copy from the template
        /// 2- has no action -> exit, need action
        /// 3- has action
        ///   3.1- Create the value by provided in the action
        ///
        /// </summary>
        /// <param name="propTempl"></param>
        /// <param name="ruleValueSetOnInst"></param>
        /// <returns></returns>
        private bool ExecPropTemplRuleValueSetOnInst(PropTempl propTempl, PropertyGroup propGroupParent, PropTemplRuleValueToSet ruleValueSetOnInst, List <PropTemplRuleActionBase> listAction, List <PropTemplRuleBase> listRulesNeedActions)
        {
            Property property = new Property();

            property.PropGroupParentId = propGroupParent.Id;
            propGroupParent.AddProperty(property);

            // 1- create the key by copy from the template
            PropertyKeyBase propKey = CreatePropKeyFromTempl(propTempl);

            property.SetKeyValue(propKey, null);

            // an action on this rule is provided?
            PropTemplRuleActionBase action = listAction.Find(a => a.RuleId.Equals(ruleValueSetOnInst.Id));

            if (action == null)
            {
                // no action provided for this rule!, need an action on this rule
                listRulesNeedActions.Add(ruleValueSetOnInst);
                // stops
                return(true);
            }

            // check the type of the action, must match the rule type!
            PropTemplRuleActionValueToSet actionSetOnInst = action as PropTemplRuleActionValueToSet;

            if (actionSetOnInst == null)
            {
                // error! action type is wrong
                return(false);
            }

            // move the rule in the list of rules executed/done
            //propTempl.MoveRuleToExecuted(ruleValueSetOnInst);

            // execute the action: create the prop Value
            //PropertyValueBase propValue = CreatePropValueFromAction(actionSetOnInst, ruleValueSetOnInst);
            IValue value = CreatePropValueFromAction(actionSetOnInst, ruleValueSetOnInst);

            // set the prop value, the key is set before
            property.SetValue(value);
            return(true);
        }
        /// <summary>
        /// Check the consistency of the property template: key and value.
        /// </summary>
        /// <param name="entityTempl"></param>
        /// <param name="propTempl"></param>
        /// <param name="listRuleToExec"></param>
        /// <returns></returns>
        private int CheckConsistencyPropTempl(EntityTempl entityTempl, PropTempl propTempl, List <PropTemplRuleBase> listRuleToExec)
        {
            int pbCount = 0;

            // check the key
            if (propTempl.Key == null)
            {
                // the key must exists!
                pbCount++;
            }

            // analyze all rules of the property template
            foreach (PropTemplRuleBase rule in propTempl.ListRule)
            {
                // save the rule to execute
                listRuleToExec.Add(rule);

                // the propTempl contains the rule PropValueToSet?
                if (rule.Type == PropTemplRuleType.PropValueToSet)
                {
                    // the property template value must be null!
                    if (!(propTempl.PropValueTempl.Value == null))
                    {
                        // TODO: prendre le membre inner (string, ...)
                        // + créer une liste d'erreurs.
                        //ici();

                        // TODO: voir selon le type!
                        pbCount++;
                    }
                }
            }

            // check: no rule to execute and the prop value is null-> error!
            if (listRuleToExec.Count == 0 && propTempl.PropValueTempl == null)
            {
                // todo:check the type of rule for tis case?? PropValueSetOnInstance
                pbCount++;
            }

            return(pbCount);
        }
        /// <summary>
        /// Create a property Template (final) from the template.
        /// process:
        ///   1- has no rule -> create the key and the value by copy from the template
        ///   2- has rule(s), scan rules:
        ///      2.1- is PropValueSetOnInstance
        ///         2.1.1- Create the key by copy from the template
        ///         2.1.2- has no action -> exit, need action
        ///         2.1.2- has action
        ///             2.1.2.1- Create the value by provided in the action
        /// </summary>
        /// <param name="propTempl"></param>
        /// <param name="propGroupParent"></param>
        /// <param name="listAction"></param>
        /// <param name="listRulesNeedActions"></param>
        /// <returns></returns>
        private bool CreatePropFromTempl(PropTempl propTempl, PropertyGroup propGroupParent, List <PropTemplRuleActionBase> listAction, List <PropTemplRuleBase> listRulesNeedActions)
        {
            // 1- has no rule -> create the key and the value by copy from the template
            if (propTempl.ListRule.Count == 0)
            {
                // create the key by copy from the template
                PropertyKeyBase propKey = _processEntPropTemplRules.CreatePropKeyFromTempl(propTempl);

                // create the value by copy from the template
                IValue   propValue = ValueToolCore.CreateValueFromTempl(propTempl.PropValueTempl);
                Property property  = new Property();
                property.PropGroupParentId = propGroupParent.Id;
                property.SetKeyValue(propKey, propValue);
                propGroupParent.AddProperty(property);
                return(true);
            }

            // 2- has rule(s), scan each one
            return(_processEntPropTemplRules.ExecRules(propTempl, propGroupParent, listAction, listRulesNeedActions));
        }
        /// <summary>
        /// Execute rules of the propTempl.
        ///
        ///   2- has rule(s), scan rules:
        ///      2.1- is PropValueSetOnInstance
        ///         2.1.1- Create the key by copy from the template
        ///         2.1.2- has no action -> exit, need action
        ///         2.1.2- has action
        ///             2.1.2.1- Create the value by provided in the action
        /// </summary>
        /// <param name="propTempl"></param>
        /// <returns></returns>
        public bool ExecRules(PropTempl propTempl, PropertyGroup propGroupParent, List <PropTemplRuleActionBase> listAction, List <PropTemplRuleBase> listRulesNeedActions)
        {
            bool res = true;

            // 2- has rule(s), scan each one
            foreach (PropTemplRuleBase rule in propTempl.ListRule)
            {
                // 2.1- is rule PropValueSetOnInstance?
                PropTemplRuleValueToSet ruleValueSetOnInst = rule as PropTemplRuleValueToSet;
                if (ruleValueSetOnInst != null)
                {
                    res &= ExecPropTemplRuleValueSetOnInst(propTempl, propGroupParent, ruleValueSetOnInst, listAction, listRulesNeedActions);
                }

                // other rule type?
                // not implemented
            }

            return(res);
        }
        public void EntOneProp_KString_VString()
        {
            EtagairCore core = Common.CreateCore(RepositConfig);

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

            // add property
            PropTempl propTempl = core.EditorTempl.CreatePropTempl(templComputer, "Type", "Computer");

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

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

            // check the property value (type and value)
            ValString propValueString = propTempl.PropValueTempl.Value as ValString;

            Assert.IsNotNull(propValueString, "the value should be a string");
            Assert.AreEqual("Computer", propValueString.Value, "the key should be 'Computer'");
        }
Пример #13
0
        public void Ent_PropGroup_Prop_KString_VString_RULToSet()
        {
            EtagairCore core = Common.CreateCoreInMemory();

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

            // create the group Core
            PropGroupTempl propGroupTemplCore = core.EditorTempl.CreatePropGroupTempl(entTemplComputer, "Core");

            // create a property template without the value: will be created on the instantiation
            PropTempl propTemplType = core.EditorTempl.CreatePropTempl(entTemplComputer, propGroupTemplCore, "Type", (string)null);

            // On prop type, Add Rule: add property, V=RULE:ToSet, type= string
            PropTemplRuleValueToSet rule = new PropTemplRuleValueToSet();

            rule.ValueType = PropValueType.String;
            core.EditorTempl.AddPropTemplRule(entTemplComputer, propTemplType, rule);

            //====Instantiate
            EntityTemplToInst templToInst = core.ProcessTempl.CreateEntity(entTemplComputer);

            Assert.AreEqual(TemplToInstState.InProgress, templToInst.State, "the state should be InProgress");
            Assert.AreEqual(TemplToInstStep.NeedAction, templToInst.NextStep, "the next step should be NeedAction");

            //---provide an action to the rule (to execute it automatically): Property value set on instantiation
            PropTemplRuleActionValueToSet action = new PropTemplRuleActionValueToSet();

            action.SetRule(rule);
            action.SetValueString("Intel");

            // adds actions to rules and create the entity
            core.ProcessTempl.AddActionsToCreateEntity(templToInst, action);

            Assert.AreEqual(TemplToInstState.InProgress, templToInst.State, "the state should be InProgress");
            Assert.AreEqual(TemplToInstStep.Starts, templToInst.NextStep, "the next step should be NeedAction");

            // create the entity, use action
            core.ProcessTempl.CompleteCreateEntity(templToInst);

            // 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 the creation

            //----check the prop group: Core
            PropertyBase  propBase  = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Core", false);
            PropertyGroup propGroup = propBase as PropertyGroup;

            Assert.IsNotNull(propGroup, "the propgroup Core should exists");

            // Check the prop group key
            PropertyKeyString propGroupKey = propGroup.Key as PropertyKeyString;

            Assert.IsNotNull(propGroupKey, "the propgroup key Core should exists");
            Assert.AreEqual("Core", propGroupKey.Key, "the key should be Core");

            //----check the property child: Type=Computer
            propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, propGroup, "Type", false);
            Property prop = propBase as Property;

            Assert.IsNotNull(prop, "the prop child Type should exists");

            // find the prop Intel (inside the group Core) from the root property
            PropertyBase propBaseTypeIntel = core.Searcher.FindPropertyByKey(templToInst.Entity, "Type", true);
            Property     propTypeIntel     = propBaseTypeIntel as Property;

            Assert.IsNotNull(propTypeIntel, "the prop child Type should exists (find from the root)");

            // check the prop key: Type, find the prop from the parent
            PropertyKeyString propKeyString = prop.Key as PropertyKeyString;

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

            // check the prop value
            //PropertyValueString propValueString = prop.Value as PropertyValueString;
            ValString propValueString = prop.Value as ValString;

            Assert.IsNotNull(propValueString, "the prop key string Type should exists");
            Assert.AreEqual("Intel", propValueString.Value, "the value should be Intel");
        }
Пример #14
0
        public void EntOneProp_KeyString_ValString_RULToSet()
        {
            EtagairCore core = Common.CreateCoreInMemory();

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

            // create a property template without the value: will be created on the instantiation
            PropTempl propTempl = core.EditorTempl.CreatePropTemplValueStringNull(templComputer, "Name");

            // Add Rule: add property, V=RULE:Toset, type= TextCode: to be set on instanciation
            PropTemplRuleValueToSet rule = new PropTemplRuleValueToSet();

            rule.ValueType = PropValueType.String;
            core.EditorTempl.AddPropTemplRule(templComputer, propTempl, rule);

            // provide an action to the rule (to execute it automatically): Property value set on instantiation
            PropTemplRuleActionValueToSet action = new PropTemplRuleActionValueToSet();

            action.SetRule(rule);
            action.SetValueString("Toshiba");

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

            Assert.AreEqual(TemplToInstState.InProgress, templToInst.State, "the state should be InProgress");
            Assert.AreEqual(TemplToInstStep.NeedAction, templToInst.NextStep, "the next step should be NeedAction");

            // adds actions to rules and create the entity
            core.ProcessTempl.AddActionsToCreateEntity(templToInst, action);
            Assert.AreEqual(TemplToInstState.InProgress, templToInst.State, "the state should be InProgress");
            Assert.AreEqual(TemplToInstStep.Starts, templToInst.NextStep, "the next step should be Starts");

            // create the entity, use action
            core.ProcessTempl.CompleteCreateEntity(templToInst);

            // 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 property: Name=Toshiba
            PropertyBase propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Name", false);

            Assert.IsNotNull(propBase, "the propBase Type=Computer should exists");
            Property prop = propBase as Property;

            Assert.IsNotNull(prop, "the prop Type=Computer should exists");

            //----check the prop key
            PropertyKeyString propKeyString = prop.Key as PropertyKeyString;

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

            //----check the prop value
            //PropertyValueString propValueValue = prop.Value as PropertyValueString;
            ValString propValueString = prop.Value as ValString;

            Assert.IsNotNull(propValueString, "the prop key string Typeshould exists");
            Assert.AreEqual("Toshiba", propValueString.Value, "the prop value should be Toshiba");
        }