Ejemplo n.º 1
0
        public void UT_Rule_InitSupplier()
        {
            boot.Init();
            mod.sr.SetModel(boot);
            Doc dRul = Doc.getDoc("Rules");

            Assert.IsNotNull(dRul);

            // test 1: Init one Rule
            Rule r = new Rule(4 + 3);

            r.Init();
            var csDP = r.CompSet.csDP;

            Assert.IsNotNull(csDP);
            bool b = csDP.dpStr.ContainsKey(SType.UNIT_Weight);

            // test 2: Check if all Rules have CompSet with Section Unit_
            mod = mod.sr.SetModel(boot, initSupl: true);
            Assert.IsTrue(mod.Rules.Count > 0);
            foreach (var rule in mod.Rules)
            {
                csDP = rule.CompSet.csDP;
                bool bw = csDP.dpStr.ContainsKey(SType.UNIT_Weight);
                bool bv = csDP.dpStr.ContainsKey(SType.UNIT_Vol);
                Assert.IsTrue(bw || bv);
            }

            FileOp.AppQuit();
        }
Ejemplo n.º 2
0
        public void UT_CheckModelIntegrity()
        {
            boot.Init();
            model = model.sr.SetModel(boot);

            // test 1: текущий режим TSmatch, 2017/12/1 проверял с Tekla

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);
            Assert.IsTrue(model.dir.Length > 0);
            Assert.IsTrue(FileOp.isDirExist(model.dir));
            Assert.IsTrue(model.date > Decl.OLD && model.date <= DateTime.Now);
            Assert.IsTrue(model.pricingDate > Decl.OLD && model.pricingDate <= DateTime.Now);
            Assert.AreEqual(32, model.MD5.Length);
            Assert.AreEqual(32, model.pricingMD5.Length);
            Assert.IsTrue(model.elements.Count > 0);
            Assert.IsTrue(model.elmGroups.Count > 0);

            // test 2: no Tekla active
            //boot.isTeklaActive = false;
            //boot.ModelDir = @"C:\TeklaStructuresModels\2017\Медиа-центр футбольного стадиона";
            //!! отложил на потом

            FileOp.AppQuit();
        }
Ejemplo n.º 3
0
        public void UT_getSavedRules()
        {
            init();

            // test no Rules Init
            model = U._GetSavedRules(model, init_mode: false);

            Assert.IsTrue(model.Rules.Count > 0);
            foreach (var rule in model.Rules)
            {
                Assert.IsNull(rule.Supplier);
                Assert.IsNull(rule.CompSet);
            }

            // test with Rules Init = true
            model = U._GetSavedRules(model, init_mode: true);

            Assert.IsTrue(model.Rules.Count > 0);
            foreach (var rule in model.Rules)
            {
                Assert.IsNotNull(rule.Supplier);
                Assert.IsNotNull(rule.CompSet);
                Assert.IsTrue(rule.CompSet.Components.Count > 0);
            }

            FileOp.AppQuit();
        }
Ejemplo n.º 4
0
        public void UT_getMD5()
        {
            boot.Init();
            Assert.AreEqual(0, mod.elements.Count);

            // test empty list of elements MD5
            string md5 = mod.getMD5(mod.elements);

            Assert.AreEqual("4F76940A4522CE97A52FFEE1FBE74DA2", md5);

            // test getMD5 with Raw()
            mod          = mod.sr.SetModel(boot);
            mod.elements = mod.sr.Raw(mod);
            Assert.IsTrue(mod.elements.Count > 0);
            string MD5 = mod.getMD5(mod.elements);

            Assert.AreEqual(32, MD5.Length);
            Assert.IsTrue(MD5 != md5);

            // test -- проверка повторного вычисления MD5
            string MD5_1 = mod.getMD5(mod.elements);

            Assert.AreEqual(MD5_1, MD5);

            FileOp.AppQuit();
        }
Ejemplo n.º 5
0
        public void UT_GetTSmatchINFO_NoFile()
        {
            // GetModelINFO() - базовый метод, вызываемый в SetModel.
            //..поэтому пользоваться обычным init() для этого UT_ нельзя
            const string defaultModName = "MyTestName";

            boot      = new Boot(); boot.Init();
            model     = new Mod();
            model.dir = boot.ModelDir;
            if (string.IsNullOrEmpty(model.dir))
            {
                model.dir = boot.DebugDir;
            }
            Assert.IsTrue(model.dir.Length > 0);
            bool isModelINFOexists = FileOp.isFileExist(model.dir, "TSmatchINFO.xlsx");

            if (isModelINFOexists)
            {
                goto exit;
            }

            U._GetTSmatchINFO(model);

            bool ok = model.sr.CheckModelIntegrity(model);

            if (isModelINFOexists)
            {
                Assert.IsTrue(model.isChanged);
            }
            Assert.IsTrue(ok);
            exit : FileOp.AppQuit();
        }
Ejemplo n.º 6
0
        public void UT_getGrps()
        {
            var mh = new MH();
            var sr = new SR();

            if (boot.isTeklaActive)
            {
                mod.dir = TS.GetTeklaDir(TS.ModelDir.model);
            }
            else
            {
                mod.dir = boot.ModelDir;
            }

            mod.elements = sr.Raw(mod);
            string md5 = mod.getMD5(mod.elements);

            Assert.AreEqual(32, md5.Length);

            var grp = mh.getGrps(mod.elements);

            Assert.IsTrue(grp.Count > 0);
            string pricing_md5 = mod.get_pricingMD5(grp);

            Assert.AreEqual(32, pricing_md5.Length);

            FileOp.AppQuit();
        }
Ejemplo n.º 7
0
        public void UT_get_pricingMD5()
        {
            Assert.AreEqual(0, mod.elements.Count);
            Assert.AreEqual(0, mod.elmGroups.Count);

            // test empty list of groups pricingMD5
            string       pricingMD5 = mod.get_pricingMD5(mod.elmGroups);
            const string EMPTY_GROUP_LIST_PRICINGMD5 = "5E7AD112B9369E41723DDFD797758E62";

            Assert.AreEqual(EMPTY_GROUP_LIST_PRICINGMD5, pricingMD5);

            // test real model and TSmatchINFO.xlsx
            boot.Init();
            mod          = mod.sr.SetModel(boot, initSupl: true);
            mod.elements = mod.sr.Raw(mod);
            var grp = mod.mh.getGrps(mod.elements);

            pricingMD5 = mod.get_pricingMD5(grp);

            Assert.IsNotNull(pricingMD5);
            Assert.AreEqual(32, pricingMD5.Length);
            Assert.IsTrue(EMPTY_GROUP_LIST_PRICINGMD5 != pricingMD5);

            FileOp.AppQuit();
        }
Ejemplo n.º 8
0
        // сравниваем результат PriceGr с тем, что записано в TSmatchINFO.xlsx/Report
        // группа за группой
        public void UT_PriceGr_Native()
        {
            boot.Init();
            mod = mod.sr.SetModel(boot);
            mod.sr.GetSavedRules(mod, init: true);
            var Rules = mod.Rules.ToList();

            // специально для первой же незаметчиваемой группы --30
            var nomatch = mod.mh.PriceGr(mod, mod.elmGroups[12]);


            //Act
            foreach (var gr in mod.elmGroups)
            {
                double priceExel = gr.totalPrice;
                //             int ind = Rules.FindIndex(x => x.sSupl == gr.SupplierName && x.sCS == gr.CompSetName);
                var mtch = mod.mh.PriceGr(mod, gr);
                Assert.AreEqual(Round(priceExel), Round(mtch.group.totalPrice));
                if (mtch.ok.ToString() != "Match")
                {
                    continue;
                }
                Assert.AreEqual(gr.SupplierName, mtch.rule.sSupl);
                Assert.AreEqual(gr.CompSetName, mtch.rule.sCS);

                Assert.AreEqual(gr.totalPrice, mtch.group.totalPrice);
                Assert.AreEqual(gr.SupplierName, mtch.group.SupplierName);
                Assert.AreEqual(gr.CompSetName, mtch.group.CompSetName);
                Assert.AreEqual(gr.mat, mtch.group.mat);
                Assert.AreEqual(gr, mtch.group);
            }

            FileOp.AppQuit();
        }
Ejemplo n.º 9
0
        public void UT_CheckGroups()
        {
            boot.Init();
            model = model.sr.SetModel(boot);
            var gr = new _Group();

            // test 1: проверка наличия разных материалов в одной группе (Msg.W en и ru)
            string s = gr._CheckGroups(ref model, "en", "W");

            var grps     = model.elmGroups;
            int cntUsual = grps.Count(x => x.type == Group.GrType.UsualPrice);
            int cntSpec  = grps.Count(x => x.type == Group.GrType.SpecPrice);
            int cntNo    = grps.Count(x => x.type == Group.GrType.NoPrice);
            int cntWarn  = grps.Count(x => x.type == Group.GrType.Warning);

            Assert.AreEqual(grps.Count(), cntNo + cntSpec + cntUsual + cntWarn);
            if (cntWarn > 0)
            {
                bool w = grps.Any(x => x.type == Group.GrType.Warning);
                Assert.IsTrue(w);
                Assert.AreEqual("various materials in Group [4]\r\nprofile=\"900X900\", materials \"B20\", and \"Concrete_Undefined\"", s);
                s = gr._CheckGroups(ref model, "ru", "W");
                Assert.AreEqual("разные материалы в группе [4]\r\nс профилем \"900X900\", материалы \"B20\" и \"Concrete_Undefined\"", s);
            }

            // test 2: проверка (Msg.F en и ru)
            model.elements.Clear();
            s = gr._CheckGroups(ref model, "en", "F");
            Assert.AreEqual("bad element or group list in model \"ONPZ-RD-ONHP-3314-1075_1.001-CI_3D_Tekla\" ", s);
            s = gr._CheckGroups(ref model, "ru", "F");
            Assert.AreEqual("ошибка списка элементов или списка групп в модели \"ONPZ-RD-ONHP-3314-1075_1.001-CI_3D_Tekla\"", s);

            FileOp.AppQuit();
        }
Ejemplo n.º 10
0
        public void UT_Recover()
        {
            init();

            model.date        = new DateTime(2015, 6, 12, 14, 15, 16);
            model.MD5         = "-- моя имитация MD5 --";
            model.pricingMD5  = "-- моя имитация MD5 --";
            model.pricingDate = new DateTime(2017, 4, 4, 20, 19, 18);
            model.setCity("Санкт-Петербург, Зенит-Арена");
            sr.resetDialog = false;

            // проверяем создание TSmatchINFO.xlsx/ModelINFO
            string repNm = Decl.TSMATCHINFO_MODELINFO;

            sr.Recover(repNm, SR.RecoverToDo.ResetRep);

            //закрываем модель и открываем ее заново для чистоты проверки
            Assert.IsTrue(Docs.IsDocExists(repNm));
            Docs modINFO = Docs.getDoc(Decl.TSMATCHINFO_MODELINFO);

            modINFO.Close();
            model = new Mod();
            Assert.IsNull(model.name);

            var      m          = Docs.getDoc(repNm).Body;
            string   modName    = m.Strng(Decl.MODINFO_NAME_R, 2);
            string   dir        = m.Strng(Decl.MODINFO_DIR_R, 2);
            string   dat        = m.Strng(Decl.MODINFO_DATE_R, 2);
            DateTime date       = Lib.getDateTime(dat);
            string   adr        = m.Strng(Decl.MODINFO_ADDRESS_R, 2);
            int      cnt        = m.Int(Decl.MODINFO_ELMCNT_R, 2);
            string   MD5        = m.Strng(Decl.MODINFO_MD5_R, 2);
            string   pricingMD5 = m.Strng(Decl.MODINFO_PRCMD5_R, 2);

            Assert.IsTrue(modName.Length > 0);
            Assert.IsTrue(dir.Length > 0);
            Assert.IsTrue(dir.Contains(@"\"));
            Assert.IsTrue(dir.Contains(":"));
            Assert.IsFalse(dir.Contains("."));
            Assert.IsTrue(dat.Length > 0);
            Assert.IsTrue(date > Decl.OLD && date < DateTime.Now);
            Assert.AreEqual("-- моя имитация MD5 --", MD5);
            Assert.AreEqual("-- моя имитация MD5 --", pricingMD5);
            Assert.AreEqual("Санкт-Петербург, Зенит-Арена", adr);

            //-- Raw теперь - отдельный xml файл, его не надо проверять 27.05.2017
            //// проверяем создание TSmatchINFO.xlsx/Raw
            //string raw = Decl.TSMATCHINFO_RAW;
            //// 4/5 долго: 2 мин            sr.Recover(raw, SR.RecoverToDo.ResetRep);
            //Assert.IsTrue(Docs.IsDocExists(raw));

            // проверяем создание TSmatchINFO.xlsx/Report
            string report = Decl.TSMATCHINFO_REPORT;

            //14/7            sr.Recover(report, SR.RecoverToDo.ResetRep);
            Assert.IsTrue(Docs.IsDocExists(report));

            FileOp.AppQuit();
        }
Ejemplo n.º 11
0
        public void UT_Mtch()
        {
            boot.Init();
            var model = mod.sr.SetModel(boot, initSupl: false);

            Assert.IsTrue(model.elmGroups.Count > 0);
            Assert.IsTrue(model.Rules.Count > 0);
            var Rules = model.Rules.ToList();
            var grps  = model.elmGroups.ToList();

            // test 1 Уголок L50x5 -> цена 7 209 руб
            Rule.Rule   rule = Rules.Find(x => x.sCS.Contains("Уголок"));
            Group.Group gr   = grps.Find(x => x.Prf.Contains("L"));
            if (rule != null && gr != null)
            {
                rule.Init();
                var m = new Mtch(gr, rule);
                Assert.IsTrue(gr.totalPrice > 7000);
                double rubPerKg = gr.totalPrice / gr.totalWeight;
                Assert.IsTrue(rubPerKg > 20);
            }

            // test 2 Полоса -30 из Листа ЛСС
            rule = Rules.Find(x => x.sCS.Contains("Лист"));
            gr   = grps.Find(x => x.Prf.Contains("—"));
            if (rule != null && gr != null)
            {
                rule.Init();
                var m = new Mtch(gr, rule);
                Assert.IsTrue(gr.totalPrice > 7000);
                double rubPerKg = gr.totalPrice / gr.totalWeight;
                Assert.IsTrue(rubPerKg > 20);
            }

            // test 3 Бетон
            rule = Rules.Find(x => x.sCS.Contains("бетон"));
            gr   = grps.Find(x => x.mat.Contains("b"));
            if (rule != null && gr != null)
            {
                rule.Init();
                var m = new Mtch(gr, rule);
                Assert.IsTrue(gr.totalPrice > 7000);
                double rubPerM3 = gr.totalPrice / gr.totalVolume; //.totalWeight;
                Assert.IsTrue(rubPerM3 > 2000);
            }
            //foreach (var gr in model.elmGroups)
            //{
            //    Assert.IsTrue(model.Rules.Count > 0);
            //    foreach (var rule in model.Rules)
            //    {
            //        Assert.IsNotNull(rule.CompSet.Supplier);
            //        Assert.IsTrue(rule.CompSet.Components.Count > 0);
            //        Mtch _match = new Mtch(gr, rule);
            //    }
            //}
            FileOp.AppQuit();
        }
Ejemplo n.º 12
0
        public void UT_Reset()
        {
            boot.Init();
            Document doc = Document.getDoc("ModelINFO", reset: true, create_if_notexist: true);

            Assert.IsNotNull(doc);
            Assert.IsTrue(doc.il > doc.i0);

            FileOp.AppQuit();
        }
Ejemplo n.º 13
0
        public void UT_DocMsg()
        {
            boot.Init();
// не написано, отложил на потом!!!!!!!!!!!!!!!!
            // test 1: getDoc("No File")
            // test 2: getDoc("No SheetN")
            //         Assert.Fail();

            FileOp.AppQuit();
        }
Ejemplo n.º 14
0
        public void UT_SetMod_native()
        {
            boot = new Boot(); boot.Init();
            var sr = new SR();

            model = sr.SetModel(boot);

            Assert.IsTrue(sr.CheckModelIntegrity(model));

            FileOp.AppQuit();
        }
Ejemplo n.º 15
0
        public void UT_Save()
        {
            init();
            model = model.sr.SetModel(boot, initSupl: false);   // with Rule Initialization

            model.sr.Save(model);

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);

            FileOp.AppQuit();
        }
Ejemplo n.º 16
0
        public void UT_EOL()
        {
            boot.Init();
            string sIR = "InitialRules";

            var doc = Document.getDoc(sIR);

            Assert.AreEqual(sIR, doc.name);
            Assert.AreEqual(4, doc.i0);
            Assert.AreEqual(15, doc.il);

            FileOp.AppQuit();
        }
Ejemplo n.º 17
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();
        }
Ejemplo n.º 18
0
        public void UT_PriceList_CheclAll()
        {
            Boot boot = new Boot();

            boot.Init();

            var p = new PriceList();

            p.CheckAll();

            Assert.IsTrue(2 * 2 == 4);

            FileOp.AppQuit();
        }
Ejemplo n.º 19
0
        public void UT_Pricing()
        {
            boot.Init();
            mod = mod.sr.SetModel(boot);
            double priceExcel = mod.total_price;    // price from Excel

            // test 0: по одной или более групп match найден.
            mod.mh.Pricing(ref mod);
            Assert.IsTrue(mod.matches.Count > 0);
            if (mod.name == "Chasovnya+lepestok")
            {
                bool c235found = false;
                foreach (var r in mod.Rules)
                {
                    if (!r.text.Contains("235"))
                    {
                        continue;
                    }
                    c235found = true;
                    break;
                }
                Assert.IsTrue(c235found);
            }

            // test 1: посчитана общая цена проекта
            double totalPrice = 0;

            foreach (var match in mod.matches)
            {
                totalPrice += match.group.totalPrice;
            }
            Assert.IsTrue(totalPrice > 1000);
            priceExcel = Math.Round(priceExcel / 1000000, 1);
            totalPrice = Math.Round(totalPrice / 1000000, 1);
            Assert.AreEqual(totalPrice, priceExcel);

            if (mod.name == "ONPZ-RD-ONHP-3314-1075_1.001-CI_3D_Tekla")
            {
                Assert.AreEqual(21, mod.matches.Count);
                // в Excel 8117835,38862033 rub
                double x = Math.Round(8117835.38862033 / 1000000, 1);
                Assert.AreEqual(8.1, x);
                double p = Math.Round(mod.total_price / 1000000, 1);
                Assert.AreEqual(6.1, p);
            }

            FileOp.AppQuit();
        }
Ejemplo n.º 20
0
        public void UT_GetSavedReport()
        {
            init();
            U._GetTSmatchINFO(model);

            model = U._GetSavedReport();

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);

            var total_price = model.elmGroups.Sum(x => x.totalPrice);

            Assert.IsTrue(model.elmGroups.Sum(x => x.totalPrice) > 0);

            FileOp.AppQuit();
        }
Ejemplo n.º 21
0
        public void UT_SR_Raw()
        {
            init();

            model.elements = model.sr.Raw(model);

            Assert.IsTrue(model.elements.Count > 0);
            Assert.IsTrue(model.date > Decl.OLD & model.date < DateTime.Now);
            Assert.AreEqual(32, model.MD5.Length);

            foreach (var elm in model.elements)
            {
                Assert.AreEqual(38, elm.guid.Length);
            }

            FileOp.AppQuit();
        }
Ejemplo n.º 22
0
        public void getDoc()
        {
            boot.Init();

            // test 1: getDoc() => TOC
            Document toc = Document.getDoc();   // static getDoc()

            Assert.AreEqual(toc.name, "TOC");

            //test 2: getDoc(ModelINFO)
            if (Document.IsDocExist("ModelInfo"))
            {
                Document doc = Document.getDoc("ModelINFO", reset: false);
                Assert.AreEqual(doc.il > 9, true);
            }

            //test 3: getDoc(InitRules)
            Document ir = Document.getDoc("InitialRules");

            Assert.AreEqual("InitialRules", ir.name);
            Assert.AreEqual(4, ir.i0);
            Assert.AreEqual(15, ir.il);


            //test 4: getDoc("ГК Монолит")
            string   docName = "ГК Монолит";
            Document d       = Document.getDoc(docName);

            Assert.AreEqual(docName, d.name);
            Assert.AreEqual(8, d.i0);
            Assert.AreEqual(15, d.il);

            //-- реализация Get без static - еще не работает 20/4/17
            ////Document doc = doc.Get();           // возвращает TOC
            ////Assert.AreEqual(doc.name, "TOC");

            ////string name = "docNotExists";
            ////doc = new Document(name);
            ////Assert.AreEqual(doc.name, name);

            ////doc.Get(name);  // читает из файла name
            ////Assert.Fail();

            FileOp.AppQuit();
        }
Ejemplo n.º 23
0
        public void UT_Rule_Constructor()
        {
            boot.Init();
            mod.sr.SetModel(boot);

            Rule rule = new Rule(5);

            Assert.IsNotNull(rule);
            Assert.AreEqual(rule.sSupl, "СтальХолдинг");
            Assert.AreEqual(rule.sCS, "Уголок равнопол.");

            // test Exception
            // при ошибке в файле Rules, конструктор возвращает в е номер строки файла, где ошибка
            try { new Rule(2); }
            catch (InvalidCastException e) { };

            FileOp.AppQuit();
        }
Ejemplo n.º 24
0
        public void UT_Start()
        {
            boot.Init();
            var Documents = Document.__Documents();

            Assert.IsTrue(Documents.Count > 50);

            // test InitialRules
            string   sIR = "InitialRules";
            Document ir  = Documents[sIR];

            //            ir.
            Assert.AreEqual(4, ir.i0);
            Assert.AreEqual(15, ir.il);

            Assert.IsTrue(true);

            FileOp.AppQuit();
        }
Ejemplo n.º 25
0
        public void UT_CheckModelIntegrity_native()
        {
            boot  = new Boot(); boot.Init();
            model = new Mod();
            model = model.sr.SetModel(boot);

            bool ok = model.sr.CheckModelIntegrity(model);

            Assert.IsTrue(ok);
            Assert.IsTrue(model.dir.Length > 0);
            Assert.IsTrue(FileOp.isDirExist(model.dir));
            Assert.IsTrue(model.date > Decl.OLD && model.date <= DateTime.Now);
            Assert.IsTrue(model.pricingDate > Decl.OLD && model.pricingDate <= DateTime.Now);
            Assert.AreEqual(32, model.MD5.Length);
            Assert.AreEqual(32, model.pricingMD5.Length);
            Assert.IsTrue(model.elements.Count > 0);
            Assert.IsTrue(model.elmGroups.Count > 0);

            FileOp.AppQuit();
        }
Ejemplo n.º 26
0
        public void UT_Rule_SynParse()
        {
            boot.Init();
            mod = mod.sr.SetModel(boot);
            var Rules = mod.Rules.ToList();

            // test 0: синонимы по материалам M:С235=C245
            Rule rule = Rules.Find(x => x.text.Contains("c255=c245=c235"));

            if (rule != null)
            {
                var SynsM = rule.synonyms[SType.Material];
                Assert.IsTrue(SynsM.Count >= 3);
                Assert.AreEqual("c255", SynsM[0]);
                Assert.AreEqual("c245", SynsM[1]);
                Assert.AreEqual("c235", SynsM[2]);
            }

            FileOp.AppQuit();
        }
Ejemplo n.º 27
0
 public void UT_comp_InSh_Native()
 {
     boot.Init();
     // test 1 Native: Балка 35 Ш2 СТО АСЧМ 20-93 ст3сп/пс5
     model = model.sr.SetModel(boot);
     foreach(var gr in model.elmGroups)
     {
         if(!gr.prf.Contains("i") || !gr.prf.Contains("ш") )continue;
         string rText = string.Empty;
         foreach(var r in model.Rules)
         {
             if (r.sSupl != "ЛенСпецСталь" || r.sCS != "Двутавр") continue;
             rText = r.Text;
             r.Init();
             Assert.IsTrue(r.CompSet.Components.Count > 5);
             var m = new Mtch(gr, r);
             Assert.AreEqual("Match", m.ok.ToString());
         }
     }
     exit: FileOp.AppQuit();
 }
Ejemplo n.º 28
0
        public void UT_isDocExists()
        {
            Assert.IsFalse(Document.IsDocExist("TOC"));     // до вызова Boot документ ТОС не существует
            boot.Init();
            Assert.IsTrue(Document.IsDocExist("TOC"));      // поле Boot - OK
            Assert.IsTrue(Document.IsDocExist());
            Assert.IsFalse(Document.IsDocExist("bla-bla")); // заведомо не существующий документ

            // test 1: chech if Tab "ModelINFO" exist in current TSmatchINFO.xlsx
            //         if NOT - check Doc UT_Docunent in UT_Debug.xlsx
            string   sINFO = "ModelINFO";
            Document rep   = Document.getDoc(sINFO, create_if_notexist: false, fatal: false);
            bool     ok    = false;

            if (rep != null)
            {
                ok = Document.IsDocExist(sINFO);
            }
            else
            {
                string   sUTdoc = "UT_Document";
                Document ut_doc = Document.getDoc(sUTdoc);
                ok = Document.IsDocExist(sUTdoc);
            }

            Assert.IsTrue(ok);

            // тут не надо делать тест с созданим Документа и его стиранием -
            //..'это можно делать в другихUT_Document
            //Document doc = Document.getDoc(sINFO, create_if_notexist: true, fatal: false, reset: true);
            //    Assert.IsTrue(Document.IsDocExist(sINFO));
            //    doc.Close();
            //    //31/7                FileOp.Delete(doc.FileDirectory, name + ".xlsx");
            //    Assert.IsFalse(Document.IsDocExist(sINFO))

            FileOp.AppQuit();
        }
Ejemplo n.º 29
0
        public void UT_elmGroups()
        {
            boot.Init(false);
            List <Elm>   elms = new List <Elm>();
            List <ElmGr> grps = new List <ElmGr>();

            if (boot.isTeklaActive)
            {
                model.dir = boot.ModelDir;
            }
            else
            {
                model.dir = boot.DebugDir;
            }
            Assert.IsFalse(model.dir == null);
            elms = model.sr.Raw(model);
            Assert.IsTrue(elms.Count > 0);

            grps = model.mh.getGrps(elms);

            Assert.IsTrue(grps.Count > 1);

            FileOp.AppQuit();
        }
Ejemplo n.º 30
0
        public void UT_CompSet_init_Naive()
        {
            boot.Init();
            Mod mod = new Mod();

            // test 0: бетон -> должен быть DP[UNIT_Vol]
            Supl    spl = new Supl("ГК Монолит СПб");
            CompSet csb = new CompSet("Товарный бетон", spl);

            Assert.IsNotNull(csb);
            Assert.IsNotNull(csb.csDP);
            Assert.AreEqual(4, csb.csDP.dpStr.Count);
            Assert.IsTrue(csb.csDP.dpar.ContainsKey(SType.UNIT_Vol));

            // test 1: after bug "Ед: руб/т" не попадал в compDP -> compDP содержит SType.UNIT_Weight
            Supl    supl = new Supl("ЛенСпецСталь");
            CompSet cs   = new CompSet("Полоса", supl);

            Assert.IsTrue(cs.csDP.dpar.ContainsKey(SType.UNIT_Weight));


            // test 2: Check if all Rules have CompSet with Section Unit_
            mod = mod.sr.SetModel(boot, initSupl: true);
            Assert.IsTrue(mod.Rules.Count > 0);
            Rule.Rule r = mod.Rules.ToList()[3];

            foreach (var rule in mod.Rules)
            {
                var  csDP = rule.CompSet.csDP;
                bool bw   = csDP.dpStr.ContainsKey(SType.UNIT_Weight);
                bool bv   = csDP.dpStr.ContainsKey(SType.UNIT_Vol);
                Assert.IsTrue(bw || bv);
            }

            FileOp.AppQuit();
        }