public void EntOneProp_KString_VBool() { EtagairCore core = Common.CreateCore(RepositConfig); // create an entity template to instantiate EntityTempl templComputer = core.EditorTempl.CreateEntityTempl("TemplComputer"); // add property core.EditorTempl.CreatePropTempl(templComputer, "Count", true); //====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 ValBool propValueBool = prop.Value as ValBool; Assert.IsNotNull(propValueBool, "the prop key bool Count should exists"); Assert.AreEqual(true, propValueBool.Value, "the value should be 12.0"); }
public void Create_1000_Entities_Empty() { EtagairCore core = Common.CreateCore(RepositConfig); //==== creates entities, with prop //----create entities Entity entity; int count = 1000; // Create new stopwatch. Stopwatch stopwatch = new Stopwatch(); // Begin timing. stopwatch.Start(); for (int i = 0; i < count; i++) { entity = core.Editor.CreateEntity(); } // Stop timing. stopwatch.Stop(); // check the entities count int countFound = core.Editor.GetRootFolder().ListChildId.Count; Assert.AreEqual(count, countFound, "Missing some entities!"); // should takes around 7-8 sec Assert.IsTrue(stopwatch.Elapsed.TotalSeconds < 12, "Takes too many times!"); }
public void ChangeCurrentLang_GetTextLocal_ok() { EtagairCore core = Common.CreateCore(RepositConfig); //----Define languages in the current catalog core.Editor.DefineLanguage(LanguageCode.en); // ->becomes the default language core.Editor.DefineLanguage(LanguageCode.fr); // create textCode and translation TextCode tcName = core.Editor.CreateTextCode("Name"); TextLocalModel tl_en_Name = core.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); TextLocalModel tl_fr_Name = core.Editor.CreateTextLocalModel(LanguageCode.fr, tcName, "Nom"); // create textCode and translation TextCode tcNameToshiba = core.Editor.CreateTextCode("NameToshiba"); core.Editor.CreateTextLocalModel(LanguageCode.en, tcNameToshiba, "Laptop Toshiba Core i7 RAM 8Go HD 1To Win10"); core.Editor.CreateTextLocalModel(LanguageCode.fr, tcNameToshiba, "Ordinateur portable Toshiba Core i7 RAM 8Go DD 1To Win10"); // change the current language from en to fr core.Searcher.SetCurrentLanguage(LanguageCode.fr); // get localized text TextLocal tlNameFound = core.Editor.GenerateTextLocal(tcName); // should be in french Assert.AreEqual(tl_fr_Name.Id, tlNameFound.TextLocalModelId, "the TextLocal Language should be 'en'"); }
public void CreateEntity_Prop_KeyTextCode_ValTextCode() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); TextCode tcToshiba = core.Editor.CreateTextCode("Toshiba"); // create an ent Entity toshibaCoreI7 = core.Editor.CreateEntity(); // Add a property to an object: key - value Property propName = core.Editor.CreateProperty(toshibaCoreI7, tcName, tcToshiba); // 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) ValTextCodeId propValueTextCode = propName.Value as ValTextCodeId; Assert.IsNotNull(propValueTextCode, "the value should be a TextCode"); Assert.AreEqual(tcToshiba.Id, propValueTextCode.TextCodeId, "the key should be 'Toshiba'"); }
public void SearchEntities_PropKeyEqualsName() { EtagairCore core = Common.CreateCore(RepositConfig); //==== creates entities, with prop //----create entities Entity toshibaCoreI7 = core.Editor.CreateEntity(); core.Editor.CreateProperty(toshibaCoreI7, "Name", "Toshiba Satellite Core I7"); core.Editor.CreateProperty(toshibaCoreI7, "TradeMark", "Toshiba"); //==== define the search: from the root folder, select all entities having a key prop called 'Name' SearchEntity searchEntities = core.Searcher.CreateSearchEntity(SearchFolderScope.All); //--Add single criteria: property key text equals to 'Name' SearchPropCriterionKeyText criterion = core.Searcher.AddCritPropKeyText(searchEntities, "Name"); criterion.PropKeyTextType = CritOptionPropKeyTextType.AllKeyType; criterion.TextSensitive = CritOptionTextSensitive.No; criterion.TextMatch = CritOptionTextMatch.TextMatchExact; //==== execute the search, get the result: list of found entities SearchEntityResult result = core.Searcher.ExecSearchEntity(searchEntities); // check found entities Assert.AreEqual(1, result.ListEntityId.Count, "One found entities expected"); bool found; found = result.ListEntityId.Contains(toshibaCoreI7.Id); Assert.IsTrue(found, "The entity id toshibaCoreI7 should be selected"); }
public void SearchTwoEntityInFolder() { EtagairCore core = Common.CreateCore(RepositConfig); //---- create a folder, under the root Folder foldComputers = core.Editor.CreateFolder(null, "computers"); //==== creates entities, with prop //----create entities Entity toshibaCoreI7 = core.Editor.CreateEntity(foldComputers); // Add a property to an object: key - value, both are textCode (will be displayed translated, depending on the language) core.Editor.CreateProperty(toshibaCoreI7, "Name", "Toshiba Satellite Core I7"); core.Editor.CreateProperty(toshibaCoreI7, "TradeMark", "Toshiba"); Entity dellCoreI7 = core.Editor.CreateEntity(foldComputers); // Add a property to an object: key - value, both are textCode (will be displayed translated depending on the language) core.Editor.CreateProperty(dellCoreI7, "Name", "Dell Inspiron 15-5570-sku6"); core.Editor.CreateProperty(dellCoreI7, "TradeMark", "Dell"); //---check, find the entities Entity toshibaCoreI7Found = core.Searcher.FindEntityById(toshibaCoreI7.Id); Assert.IsNotNull(toshibaCoreI7Found, "The entity should exists"); Entity dellCoreI7Found = core.Searcher.FindEntityById(dellCoreI7.Id); Assert.IsNotNull(dellCoreI7Found, "The entity dellCoreI7 should exists"); }
public void SearchEntities_DefinedFolders_2_OnePropKeyEqualsName_E_F1_2E_F2_2E() { EtagairCore core = Common.CreateCore(RepositConfig); //==== creates entities, with prop //----create entities Entity toshibaCoreI7 = core.Editor.CreateEntity(); core.Editor.CreateProperty(toshibaCoreI7, "Name", "Toshiba Satellite Core I7"); core.Editor.CreateProperty(toshibaCoreI7, "TradeMark", "Toshiba"); //---- create a folder, under the root Folder foldComputers = core.Editor.CreateFolder(null, "computers"); Entity dellCoreI7 = core.Editor.CreateEntity(foldComputers); core.Editor.CreateProperty(dellCoreI7, "Name", "Dell Inspiron 15-5570-sku6"); core.Editor.CreateProperty(dellCoreI7, "TradeMark", "Dell"); Entity HPCoreI7 = core.Editor.CreateEntity(foldComputers); core.Editor.CreateProperty(HPCoreI7, "Nom", "HP Core i7"); core.Editor.CreateProperty(HPCoreI7, "TradeMark", "HP"); //---- create a folder, under the root Folder foldOthers = core.Editor.CreateFolder(null, "others"); Entity asusCoreI7 = core.Editor.CreateEntity(foldOthers); core.Editor.CreateProperty(asusCoreI7, "Name", "Asus Core i7"); core.Editor.CreateProperty(asusCoreI7, "TradeMark", "Asus"); //==== define the search: from the root folder, select all entities having a key prop called 'Name' SearchEntity searchEntities = core.Searcher.CreateSearchEntity(SearchFolderScope.Defined); //--Add sources folders, set option: go inside folders childs core.Searcher.AddSourceFolder(searchEntities, foldComputers, true); // add a second source folder core.Searcher.AddSourceFolder(searchEntities, foldOthers, true); //--Add single criteria: property key text equals to 'Name' SearchPropCriterionKeyText criterion = core.Searcher.AddCritPropKeyText(searchEntities, "Name"); criterion.TextMatch = CritOptionTextMatch.TextMatchExact; criterion.PropKeyTextType = CritOptionPropKeyTextType.AllKeyType; //==== execute the search, get the result: list of found entities SearchEntityResult result = core.Searcher.ExecSearchEntity(searchEntities); // check found entities Assert.AreEqual(2, result.ListEntityId.Count, "2 found entity expected"); bool found; found = result.ListEntityId.Contains(dellCoreI7.Id); Assert.IsTrue(found, "The entity id dellCoreI7 should be selected"); found = result.ListEntityId.Contains(asusCoreI7.Id); Assert.IsTrue(found, "The entity id asusCoreI7 should be selected"); }
public void CreateEntityPropGroup() { EtagairCore core = Common.CreateCore(RepositConfig); // create an ent Entity toshibaCoreI7 = core.Editor.CreateEntity(); // add a properties group (folder inside object) in the object PropertyGroup propGrpProc = core.Editor.CreatePropertyGroup(toshibaCoreI7, "Processor"); Assert.IsNotNull(propGrpProc, " The PG Processor should exists"); // get the prop group PropertyGroup propGrpProcGet = toshibaCoreI7.PropertyRoot.ListProperty[0] as PropertyGroup; Assert.IsNotNull(propGrpProcGet, " The PG Processor should exists"); Assert.AreEqual("Processor", Common.GetPropertyKeyContent(propGrpProcGet.Key), "The Processor key text is wrong"); PropertyGroup propGrpProc2 = core.Editor.CreatePropertyGroup(toshibaCoreI7, "Processor"); Assert.IsNull(propGrpProc2, " This second PG Processor should not exists"); // create prop childs into the prop group core.Editor.CreateProperty(toshibaCoreI7, propGrpProc, "Constructor", "Intel"); Assert.AreEqual(1, propGrpProc.ListProperty.Count, "The prop group should have one prop childs"); Property propContructorIntel = propGrpProc.ListProperty[0] as Property; Assert.AreEqual("Constructor", Common.GetPropertyKeyContent(propContructorIntel.Key), "the prop child key should be: Constructor"); Assert.AreEqual("Intel", Common.GetPropertyValueContent(propContructorIntel.Value), "the prop child key should be: Constructor"); // create another prop childs into the prop group core.Editor.CreateProperty(toshibaCoreI7, propGrpProc, "Model", "i7"); Assert.AreEqual(2, propGrpProc.ListProperty.Count, "The prop group should have 2 prop childs"); }
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"); }
public void CreateTextCode_codeNull_Failed() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode(""); Assert.IsNull(tcName, "can't be created"); }
public void CreateTextCode() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); Assert.IsNotNull(tcName.Id, "id should be set"); }
public void NoLangDefinedNoCurrentLang() { EtagairCore core = Common.CreateCore(RepositConfig); // get the current/default language: the first one defined Language lang = core.Searcher.GetCurrentLanguage(); Assert.IsNull(lang, "Lang should NOT exists"); }
public void CreateTextCode_Find_Ok() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); TextCode tcNameFind = core.Searcher.FindTextCodeById(tcName.Id); Assert.AreEqual(tcName.Code, tcNameFind.Code, "Both Code should match"); }
public void CreateTextLocal_NoLanguageDefined_Failed() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); TextLocalModel tlmName = core.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); Assert.IsNull(tlmName, "should be null, lang is not defined"); }
// TODO: gérer trad finale absente -> selectionne la mainLang // exp: pas de texte en fr_FR mais existe en fr, prend ce dernier. /// <summary> /// select entities having a property key='Name' /// /// computers\ /// Ent: Name=Toshiba Ok, selected /// Ent: Name=Dell Ok, selected /// Ent: Company=HP --NOT selected /// /// </summary> /// <param name="core"></param> static void TestSearchEntity(EtagairCore core) { Console.WriteLine("====>TestSearchEntity: "); //---- create a folder, under the root Folder foldComputers = core.Editor.CreateFolder(null, "computers"); //==== creates entities, with prop //----create entity Entity toshibaCoreI7 = core.Editor.CreateEntity(foldComputers); core.Editor.CreateProperty(toshibaCoreI7, "Name", "Toshiba Satellite Core I7"); core.Editor.CreateProperty(toshibaCoreI7, "TradeMark", "Toshiba"); //----create entity Entity dellCoreI7 = core.Editor.CreateEntity(foldComputers); core.Editor.CreateProperty(dellCoreI7, "Name", "Dell Inspiron 15-5570-sku6"); core.Editor.CreateProperty(dellCoreI7, "TradeMark", "Dell"); //----create entity Entity HPCoreI7 = core.Editor.CreateEntity(foldComputers); core.Editor.CreateProperty(HPCoreI7, "Company", "HP Core i7"); core.Editor.CreateProperty(HPCoreI7, "TradeMark", "HP"); //==== define the search: from the root folder, select all entities having a key prop called 'Name' SearchEntity searchEntities = core.Searcher.CreateSearchEntity(SearchFolderScope.Defined); //--Add sources folders, set option: go inside folders childs core.Searcher.AddSourceFolder(searchEntities, foldComputers, true); //--Add criteria: (a boolean expression) SearchPropCriterionKeyText criterion = core.Searcher.AddCritPropKeyText(searchEntities, "Name"); criterion.PropKeyTextType = CritOptionPropKeyTextType.AllKeyType; criterion.TextMatch = CritOptionTextMatch.TextMatchExact; //--set options // TODO: lesquelles? //==== execute the search, get the result: list of found entities SearchEntityResult result = core.Searcher.ExecSearchEntity(searchEntities); // displays found entities Console.WriteLine("-Search result: nb=" + result.ListEntityId.Count); foreach (string entityId in result.ListEntityId) { // load the entity Console.WriteLine("Ent, id: " + entityId); } }
public void CreateEntTempl() { EtagairCore core = Common.CreateCore(RepositConfig); // create an entity template to instantiate EntityTempl entityTempl = core.EditorTempl.CreateEntityTempl("entityTempl"); Assert.IsNotNull(entityTempl.Id, "the id should be set"); Assert.AreEqual("entityTempl", entityTempl.Name, "the name is wrong"); Assert.IsNotNull(entityTempl.ParentFolderId, "the parent folder id should exists, its the root folder)"); }
public void FindEntityById() { EtagairCore core = Common.CreateCore(RepositConfig); //---- create an entity, under the root Entity entity = core.Editor.CreateEntity(null); Entity entityFound = core.Searcher.FindEntityById(entity.Id); Assert.IsNotNull(entityFound, "The entity should exists"); }
public void FindFolderById() { EtagairCore core = Common.CreateCore(RepositConfig); //---- create a folder, under the root Folder foldComputers = core.Editor.CreateFolder(null, "computers"); Folder foldComputersFound = core.Searcher.FindFolderById(foldComputers.Id); Assert.IsNotNull(foldComputersFound, "The folder should exists"); }
/// <summary> /// entity with property: /// TextCode key /// Property group /// </summary> /// <param name="core"></param> static void BuildContent(EtagairCore core) { //----set defined (activate) language codes in the current catalog core.Editor.DefineLanguage(LanguageCode.en); core.Editor.DefineLanguage(LanguageCode.en_GB); core.Editor.DefineLanguage(LanguageCode.en_US); core.Editor.DefineLanguage(LanguageCode.fr); core.Editor.DefineLanguage(LanguageCode.fr_FR); TextCode tcName = core.Editor.CreateTextCode("Name"); // should failed TextCode tcNameErr = core.Editor.CreateTextCode("Name"); // create localized text for main languages managed in the application // en -> en_uk, en_us,.... core.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); core.Editor.CreateTextLocalModel(LanguageCode.fr, tcName, "Nom"); TextCode tcNameToshiba = core.Editor.CreateTextCode("NameToshiba"); core.Editor.CreateTextLocalModel(LanguageCode.en, tcNameToshiba, "Laptop Toshiba Core i7 RAM 8Go HD 1To Win10"); core.Editor.CreateTextLocalModel(LanguageCode.fr, tcNameToshiba, "Ordinateur portable Toshiba Core i7 RAM 8Go DD 1To Win10"); //---- create a folder, under the root Folder foldComputers = core.Editor.CreateFolder(null, "computers"); //----create entities // create a computer object from scratch (not from a template), under the "computers" folder //Object toshibaCoreI7= core.Editor.CreateObject("Toshiba Core i7 RAM 8Go DD 1To Win10") <- pas de nom de var non? (par propriété nom) Entity toshibaCoreI7 = core.Editor.CreateEntity(foldComputers); // Add a property to an object: key - value, both are textCode (will be displayed translated depending on the language) core.Editor.CreateProperty(toshibaCoreI7, tcName, tcNameToshiba); // --test: can't create a property with an existing name/key, in the same group properties core.Editor.CreateProperty(toshibaCoreI7, tcName, tcNameToshiba); // create property: RAM: 8 Go(Gb) core.Editor.CreateProperty(toshibaCoreI7, "RAM", "8"); // should failed core.Editor.CreateProperty(toshibaCoreI7, "RAM", "8"); // add a properties group (folder inside object) in the object PropertyGroup propGrpProc = core.Editor.CreatePropertyGroup(toshibaCoreI7, "Processor"); PropertyGroup propGrpProc2 = core.Editor.CreatePropertyGroup(toshibaCoreI7, "Processor"); core.Editor.CreateProperty(toshibaCoreI7, propGrpProc, "Constructor", "Intel"); core.Editor.CreateProperty(toshibaCoreI7, propGrpProc, "Model", "i7"); // Create a prop: string, imageCode }
public void CreateTextCode_2times_failed() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcName = core.Editor.CreateTextCode("Name"); Assert.IsNotNull(tcName.Id, "id should be set"); TextCode tcName2 = core.Editor.CreateTextCode("Name"); Assert.IsNull(tcName2, "can't be created"); }
public void CreateTextLocal_Failed() { EtagairCore core = Common.CreateCore(RepositConfig); //----set defined (activate) language codes in the current catalog core.Editor.DefineLanguage(LanguageCode.en); TextCode tcName = core.Editor.CreateTextCode("Name"); TextLocalModel tlmName = core.Editor.CreateTextLocalModel(LanguageCode.en_GB, tcName, "Name"); Assert.IsNull(tlmName, "Can't be created"); }
// ==== Create entity with prop childs!! // group // Templ Entity, CreatePropertyGroupTempl( key) // Add properties childs // set rule for childs: One, Several, 0..N,... static void TestCore() { //IEtagairReposit reposit= CreateRepository_InMemory(); IEtagairReposit reposit = CreateRepository_LiteDB(true); EtagairCore core = CreateCore(reposit); // Dev the language and text data model. CreateLangAndTexts(core); //BuildContent(core); //TestSearchEntity(core); }
public void DefineLangBecomesCurrent() { EtagairCore core = Common.CreateCore(RepositConfig); //----set defined (activate) language codes in the current catalog core.Editor.DefineLanguage(LanguageCode.en); core.Editor.DefineLanguage(LanguageCode.en_GB); // get the current/default language: the first one defined Language lang = core.Searcher.GetCurrentLanguage(); Assert.IsNotNull(lang, "Lang should exists"); Assert.AreEqual(lang.LanguageCode, LanguageCode.en, "The current languageCode should be 'en'"); }
public static EtagairCore CreateCore(IEtagairReposit reposit) { // create the core configurator, inject the concrete repository EtagairCore core = new EtagairCore(); //----init the core: create the catalog, becomes the current catalog if (!core.Init(reposit)) { return(null); } // configure the catalog return(core); }
public void CreateEntity() { EtagairCore core = Common.CreateCore(RepositConfig); // create an ent Entity toshibaCoreI7 = core.Editor.CreateEntity(); Assert.IsNotNull(toshibaCoreI7.Id, "id should be set"); Assert.IsNotNull(toshibaCoreI7.PropertyRoot, "the prop root should exists"); Assert.IsNotNull(toshibaCoreI7.ParentFolderId, "the parent folder should exists (its the root folder)"); Assert.IsNull(toshibaCoreI7.EntityTemplId, "no entity template id is expected"); Assert.AreEqual(BuildFrom.Scratch, toshibaCoreI7.BuildFrom, "build from scratch, not from a template"); Assert.AreEqual(true, toshibaCoreI7.BuildFromScratchFinishedAuto, "BuildFromScratchFinishedAuto should be true"); Assert.AreEqual(true, toshibaCoreI7.BuildFinished, "BuildFinished should be true"); }
static EtagairCore CreateCore(IEtagairReposit reposit) { // create the core configurator, inject the concrete repository EtagairCore core = new EtagairCore(); //----init the core: create the catalog, becomes the current catalog if (!core.Init(reposit)) { Console.WriteLine("Error, Init failed, can't create the catalog, already exists."); return(null); } // configure the catalog return(core); }
public void CreateTextLocal_Ok() { EtagairCore core = Common.CreateCore(RepositConfig); //----set defined (activate) language codes in the current catalog core.Editor.DefineLanguage(LanguageCode.en); TextCode tcName = core.Editor.CreateTextCode("Name"); // create localized text for main languages managed in the application // en -> en_uk, en_us,.... TextLocalModel tlmName = core.Editor.CreateTextLocalModel(LanguageCode.en, tcName, "Name"); Assert.IsNotNull(tlmName.Id, "id should be set"); Assert.AreEqual(tcName.Id, tlmName.TextCodeId, "textCode id should match"); Assert.AreEqual("Name", tlmName.Text, "text should be set"); }
public void CreateEntityInFolder() { EtagairCore core = Common.CreateCore(RepositConfig); //---- create a folder, under the root Folder foldComputers = core.Editor.CreateFolder(null, "computers"); //==== creates entities, with prop //----create entities Entity toshibaCoreI7 = core.Editor.CreateEntity(foldComputers); // Add a property to an object: key - value, both are textCode (will be displayed translated, depending on the language) core.Editor.CreateProperty(toshibaCoreI7, "Name", "Toshiba Satellite Core I7"); core.Editor.CreateProperty(toshibaCoreI7, "TradeMark", "Toshiba"); //---check that the folder has an entity child Assert.AreEqual(1, foldComputers.ListChildId.Count, "The folder should have one entity child"); Assert.IsTrue(foldComputers.ListChildId.ContainsKey(toshibaCoreI7.Id), "The folder should have the defined entity child"); }
public void DefineLangChangeCurrent_Ok() { EtagairCore core = Common.CreateCore(RepositConfig); //----set defined (activate) language codes in the current catalog core.Editor.DefineLanguage(LanguageCode.en); core.Editor.DefineLanguage(LanguageCode.en_GB); core.Editor.DefineLanguage(LanguageCode.fr); bool res = core.Searcher.SetCurrentLanguage(LanguageCode.fr); Assert.IsTrue(res, "the setCurrentLanguage should succeded"); // get the current/default language: the first one defined Language lang = core.Searcher.GetCurrentLanguage(); Assert.IsNotNull(lang, "Lang should exists"); Assert.AreEqual(lang.LanguageCode, LanguageCode.fr, "The current languageCode should be 'fr'"); }
public void EntOneProp_KTextCode_VTextCode() { EtagairCore core = Common.CreateCore(RepositConfig); TextCode tcKeyType = core.Editor.CreateTextCode("Type"); TextCode tcValueType = core.Editor.CreateTextCode("Computer"); // create an entity template to instantiate EntityTempl templComputer = core.EditorTempl.CreateEntityTempl("TemplComputer"); // add property core.EditorTempl.CreatePropTempl(templComputer, tcKeyType, tcValueType); //====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 property: Type=Computer PropertyBase propBase = core.Searcher.FindPropertyByKey(templToInst.Entity, templToInst.Entity.PropertyRoot, "Type", 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 PropertyKeyTextCode propKeyTextCode = prop.Key as PropertyKeyTextCode; Assert.IsNotNull(propKeyTextCode, "the prop key string Type should exists"); Assert.AreEqual(tcKeyType.Id, propKeyTextCode.TextCodeId, "the prop value should be the textCode id of the text Name"); //----check the prop value ValTextCodeId propValueTextCode = prop.Value as ValTextCodeId; Assert.IsNotNull(propValueTextCode, "the prop key string Typeshould exists"); Assert.AreEqual(tcValueType.Id, propValueTextCode.TextCodeId, "the prop value should be the textCode id of text Toshiba"); }