Exemple #1
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();
        }
Exemple #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();
        }
Exemple #3
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();
        }
Exemple #4
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();
        }
Exemple #5
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();
        }
Exemple #6
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();
        }
 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();
 }
Exemple #8
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();
        }
Exemple #9
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();
        }
Exemple #10
0
        public void UT_DocMsg()
        {
            boot.Init();
// не написано, отложил на потом!!!!!!!!!!!!!!!!
            // test 1: getDoc("No File")
            // test 2: getDoc("No SheetN")
            //         Assert.Fail();

            FileOp.AppQuit();
        }
Exemple #11
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();
        }
Exemple #12
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();
        }
Exemple #13
0
        public void UT_Hndl()
        {
            //-- Assign: подготавливаем все необходимое для Hndl-
            //.. mod.elements и mod.elmGroups, инициируем Rules с загрузкой прайс-листов
            boot.Init();
            var sr = new _SR();

            mod          = sr.SetModel(boot);
            mod.elements = sr.Raw(mod);
            List <Elm> elmCopy = new List <Elm>();

            foreach (Elm elm in mod.elements)
            {
                elmCopy.Add(elm);
            }
            for (int i = 0; i < elmCopy.Count; i++)
            {
                Assert.AreEqual(elmCopy[i], mod.elements[i]);
            }
            int    cnt = mod.elements.Count;
            string MD5 = mod.getMD5(mod.elements);

            Assert.IsTrue(cnt > 0);
            string cMD5 = mod.getMD5(elmCopy);

            Assert.AreEqual(cMD5, MD5);
            if (mod.Rules == null || mod.Rules.Count == 0)
            {
                sr._GetSavedRules(mod);
            }
            var  mh   = new MH();
            Mtch mtsh = new Mtch(mod);

            mh.Hndl(ref mod);

            // проверка, что elements не испортились
            foreach (var gr in mod.elmGroups)
            {
                cnt -= gr.guids.Count();
            }
            Assert.AreEqual(0, cnt);
            Assert.AreEqual(mod.elements.Count, elmCopy.Count);
            for (int i = 0; i < elmCopy.Count; i++)
            {
                Assert.AreEqual(elmCopy[i], mod.elements[i]);
            }
            string newMD5  = mod.getMD5(mod.elements);
            string copyMD5 = mod.getMD5(elmCopy);

            Assert.AreEqual(mod.getMD5(mod.elements), MD5);

            // проверка наличия compDescription, sCS, sSupl и totalPrice в группах
            foreach (var gr in mod.elmGroups)
            {
                if (gr.totalPrice == 0)
                {
                    continue;
                }
                Assert.IsTrue(gr.compDescription.Length > 0);
                Assert.IsTrue(gr.SupplierName.Length > 0);
                Assert.IsTrue(gr.CompSetName.Length > 0);
            }

            //Hndl performance test -- 180 sec for 100 cycles ОНХП модель 1124 элемента
            //                      -- 20,4 sec 1 cycle модель "Навес над трибунами" 7128 э-тов
            int      nLoops = 1;
            DateTime t0     = DateTime.Now;

            for (int i = 0; i < nLoops; i++)
            {
                mh.Hndl(ref mod);
            }
            TimeSpan ts      = DateTime.Now - t0;
            var      secHndl = ts.TotalSeconds / nLoops;

            Assert.IsTrue(secHndl > 0.0);

            FileOp.AppQuit();
        }