public void UT_Component_checkComp_PL() { //test 1: gr="PL10*100" rule="Prf: PL=—*x*" comp="PL10x100" => TRUE gr.prf = "PL10*100"; rule.text = "Prf:PL=—*x*"; rule.ruleDP = new DPar.DPar(rule.text); rule.synonyms = rule.RuleSynParse(rule.text); comp.compDP = new DPar.DPar("PL10x100"); bool b = comp.isMatch(gr, rule); Assert.IsTrue(b); //test 2: gr="PL10*100" rule="Prf: PL=—*x@*" comp="PL10x300" => TRUE gr.prf = "pl10*100"; rule.text = "Prf:PL=—*x@*"; rule.ruleDP = new DPar.DPar(rule.text); rule.synonyms = rule.RuleSynParse(rule.text); comp.compDP = new DPar.DPar("Prf:PL10x300"); Assert.AreEqual(comp.compDP.dpar.Count, 1); Assert.AreEqual(comp.compDP.dpar[Section.Section.SType.Profile], "pl10x300"); b = comp.isMatch(gr, rule); Assert.IsTrue(b); //test 3: gr="—8" rule="М: C245=C255 ; Профиль: Полоса горячекатаная = PL = — *x*;" comp="PL8x100" => TRUE gr.prf = "—8"; rule.text = "М: C245=C255 ; Профиль: Полоса горячекатаная = PL = — *x*;"; rule.ruleDP = new DPar.DPar(rule.text); rule.synonyms = rule.RuleSynParse(rule.text); comp.compDP = new DPar.DPar("Prf:PL8x100"); Assert.AreEqual(comp.compDP.dpar.Count, 1); Assert.AreEqual(comp.compDP.dpar[Section.Section.SType.Profile], "pl8x100"); b = comp.isMatch(gr, rule); Assert.IsTrue(b); }
public void UT_PriceGr_Msg() { // Assign boot.Init(); Rule.Rule rule = new Rule.Rule(); rule.sSupl = "СтальХолдинг"; rule.sCS = "Полоса"; rule.text = "М: C245=C255 ; Профиль: Полоса горячекатаная = PL = — *x*;"; ElmGr gr = new ElmGr(); gr.SupplierName = rule.sSupl; gr.guids = new List <string>() { "guid1", "guid2" }; // test 1: Msg.F("Rules not initialyzed") English string s = sub_PriceGr(mod, gr, "en"); Assert.AreEqual("Rules in Model were not initialyzed", s); // test 2: Msg.F("Rules not initialyzed") Russian s = sub_PriceGr(mod, gr, "ru"); Assert.AreEqual("Не инциированы правила модели", s); // test 3: Rules initialyzed, works with CompSet and Components, Rule, MsgF Wrong LoadDescriptor gr.Prf = "I20"; gr.prf = "i20"; rule.text = "Профиль: Балка =I*"; string comp_txt = "Балка 20"; rule.ruleDP = new DPar.DPar(rule.text); rule.synonyms = rule.RuleSynParse(rule.text); // var syns = rule.synonyms[Section.Section.SType.Profile].ToList(); List <Comp> comps = new List <Comp>() { new Comp(new DP("Prf:I10; Price:23456")), new Comp(new DP("Prf:I20; Price:34567")) }; Supl supl = new Supl("СтальХолдинг", init: false); string LoadDescriptor = "M:1; опис:3; профиль:2; цена: 4; Ед: руб/т"; CS cs = new CS("Балка", supl, LoadDescriptor, comps); Comp comp = new Comp(); comp.compDP = new DP("Prf: " + comp_txt); mod.Rules.Add(rule); rule.CompSet = cs; s = sub_PriceGr(mod, gr, "en", _prefix: "Msg.W: "); Assert.AreEqual("CompSet_wrong_LoadDescriptor", s); FileOp.AppQuit(); }