Exemplo n.º 1
0
        public void MtchTest_C245()
        {
            //arrange Group, Components, CompSet, Rule
            var Im   = new IMIT();
            var rule = Im.IM_Rule();
            var syns = rule.synonyms[SType.Profile].ToList();

            Assert.AreEqual(syns[0], "угoлoк");
            Assert.AreEqual(syns[1], "l");
            Comp comp = rule.CompSet.Components[1];

            Assert.AreEqual(comp.Str(SType.Profile), "Уголок 20x5");
            Assert.AreEqual(comp.compDP.dpar[SType.Profile], "угoлoк20x5");
            var gr = Im.IM_Group("C245");

            Assert.AreEqual(gr.mat, "c245");
            Assert.AreEqual(gr.prf, "l20x5");
            //act
            Mtch m = new Mtch(gr, rule);

            //assert
            Assert.AreEqual(m.ok, Mtch.OK.Match);
            Assert.AreEqual(m.group.guids.Count, 2);
            Assert.AreEqual(m.component.Str(SType.Profile), "Уголок 20x5");
            Assert.AreEqual(m.group.totalPrice, 2020);
        }
Exemplo n.º 2
0
 ////////////////public CompSet(string _name, List<Component.Component> _comps, Supl _supl, Docs _doc, List<FP> _csFPs)
 ////////////////{
 ////////////////    this.name       = _name;
 ////////////////    this.Components = _comps;
 ////////////////    this.Supplier   = _supl;
 ////////////////    this.doc        = _doc;
 ////////////////    this.csFPs      = _csFPs;
 ////////////////}
 public CompSet(string _name, Supl _supl, Rule.Rule _rule)
 {
     name     = _name;
     Supplier = _supl;
     doc      = getCSdoc(Supplier, _name);
     csFPs    = _rule.Parser(FP.type.CompSet, doc.LoadDescription);
     for (int i = doc.i0; i < doc.il; i++)
     {
         Comp comp = new Comp(doc, i, csFPs);
         Components.Add(comp);
     }
 }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public Comp Im_Comp(string mat, string descr, string price)
        {
            string str = "";

            str += "M:" + mat + ";";
            str += "Descr:" + descr + ";";
            //Profile = копия из Description только для отладки!!
            str += "Profile:" + descr + ";";
            str += "Price:" + price + ";";
            DP   dp     = new DP(str);
            Comp compDP = new Comp(dp, null);

            return(compDP);
        }