public void SetLevel1UnitValueTest()
        {
            //test Level 2
            Model      model = new Model();
            ModelValue mv    = new ModelValue();

            SetModelValueSample(mv);
            //calculate Level 3 values
            mv.CalculateLevel4Values();
            mv.CalculateLevel3Values();
            //create model
            model.CreateModel();
            //GlobalData.GlobalData.globalData.if_assess_modularity = true;
            //model.TrimModel();
            model.CalculateModelWeight();
            mv.SetLevel4UnitValue(model.level4_nodes);
            mv.SetLevel3UnitValue(model.level3_nodes);
            mv.SetLevel2UnitValue(model.level2_nodes);
            mv.SetLevel1UnitValue(model.level1_nodes);
            //verify the value
            Assert.AreEqual(3.1944350372696791127913786374672, (double)model.level1_nodes[0].value, 0.0001);

            ////修剪模型的情况
            //model.CreateModel();
            //GlobalData.GlobalData.globalData.if_assess_modularity = false;
            //model.TrimModel();
            //model.CalculateModelWeight();
            //mv.SetLevel4UnitValue(model.level4_nodes);
            //mv.SetLevel3UnitValue(model.level3_nodes);
            //mv.SetLevel2UnitValue(model.level2_nodes);
            //mv.SetLevel1UnitValue(model.level1_nodes);
            ////验证数值
            //Assert.AreEqual(2.8009873001760972650572709221841, (double)model.level1_nodes[0].value, 0.0001);
        }
        public void SetLevel2UnitValueTest()
        {
            //test Level 2
            Model      model = new Model();
            ModelValue mv    = new ModelValue();

            SetModelValueSample(mv);
            //calculate Level 3 values
            mv.CalculateLevel4Values();
            mv.CalculateLevel3Values();
            //create model
            model.CreateModel();
            //GlobalData.GlobalData.globalData.if_assess_modularity = true;
            //model.TrimModel();
            model.CalculateModelWeight();
            mv.SetLevel4UnitValue(model.level4_nodes);
            mv.SetLevel3UnitValue(model.level3_nodes);
            mv.SetLevel2UnitValue(model.level2_nodes);
            //verify the value
            Assert.AreEqual(-0.5814090208767396425967497017122, (double)model.level2_nodes[0].value, 0.0001);
            Assert.AreEqual(4.5493525993415009929712588253279, (double)model.level2_nodes[1].value, 0.0001);
            Assert.AreEqual(4.435102352522840320814015528183, (double)model.level2_nodes[2].value, 0.0001);
            Assert.AreEqual(4.37469421809111477997698989807, (double)model.level2_nodes[3].value, 0.0001);

            ////修剪模型的情况
            //model.CreateModel();
            //GlobalData.GlobalData.globalData.if_assess_modularity = false;
            //model.TrimModel();
            //model.CalculateModelWeight();
            //mv.SetLevel4UnitValue(model.level4_nodes);
            //mv.SetLevel3UnitValue(model.level3_nodes);
            //mv.SetLevel2UnitValue(model.level2_nodes);
            ////验证数值
            //Assert.AreEqual(-0.5814090208767396425967497017122, (double)model.level2_nodes[0].value, 0.0001);
            //Assert.AreEqual(4.5493525993415009929712588253279, (double)model.level2_nodes[1].value, 0.0001);
            //Assert.AreEqual(4.435102352522840320814015528183, (double)model.level2_nodes[2].value, 0.0001);
        }
        public void SetLevel3UnitValueTest()
        {
            Model      model = new Model();
            ModelValue mv    = new ModelValue();

            SetModelValueSample(mv);
            //calculate Level 3 values
            mv.CalculateLevel4Values();
            mv.CalculateLevel3Values();

            model.CreateModel();
            //GlobalData.GlobalData.globalData.if_assess_modularity = true;
            //model.TrimModel();
            model.CalculateModelWeight();
            mv.SetLevel4UnitValue(model.level4_nodes);
            mv.SetLevel3UnitValue(model.level3_nodes);
            mv.SetLevel3UnitValue(model.level2_nodes);
            mv.SetLevel3UnitValue(model.level1_nodes);
            //verify the value of Level 3
            Assert.AreEqual(17.28380m / 12.23456m, model.level3_nodes[0].value);
            Assert.AreEqual(12.23456m / 23.45678m, model.level3_nodes[1].value);
            Assert.AreEqual(42.71615m / (12.23456m * 12.23456m - 12.23456m), model.level3_nodes[2].value);
            Assert.AreEqual((67.28380m + 92.71615m) / 12.23456m, model.level3_nodes[3].value);
            Assert.AreEqual(17.28380m / 12.23456m, model.level3_nodes[4].value);
            Assert.AreEqual(12.23456m / 23.45678m, model.level3_nodes[5].value);
            Assert.AreEqual((67.28380m * 67.28380m) / (23.45678m * 23.45678m), model.level3_nodes[6].value);
            Assert.AreEqual((117.28380m * 117.28380m) / (67.28380m * 67.28380m), model.level3_nodes[7].value);
            Assert.AreEqual(3 / 12.23456m, model.level3_nodes[8].value);
            Assert.AreEqual((117.28380m * 117.28380m) / (67.28380m * 67.28380m), model.level3_nodes[9].value);
            Assert.AreEqual(3 / 12.23456m, model.level3_nodes[10].value);
            Assert.AreEqual(12.23456m / 23.45678m, model.level3_nodes[11].value);
            Assert.AreEqual((67.28380m * 67.28380m) / (23.45678m * 23.45678m), model.level3_nodes[12].value);
            //verify the value of Level 2
            foreach (var node in model.level2_nodes)
            {
                Assert.AreEqual(0, node.value);
            }
            //verify the value of Level 1
            foreach (var node in model.level1_nodes)
            {
                Assert.AreEqual(0, node.value);
            }

            ////裁剪模型的情况
            //model.CreateModel();
            //GlobalData.GlobalData.globalData.if_assess_modularity = false;
            //model.TrimModel();
            //model.CalculateModelWeight();
            //mv.SetLevel4UnitValue(model.level4_nodes);
            //mv.SetLevel3UnitValue(model.level3_nodes);
            //mv.SetLevel3UnitValue(model.level2_nodes);
            //mv.SetLevel3UnitValue(model.level1_nodes);
            ////验证第3层的值
            //Assert.AreEqual(17.28380m / 12.23456m, model.level3_nodes[0].value);
            //Assert.AreEqual(12.23456m / 23.45678m, model.level3_nodes[1].value);
            //Assert.AreEqual(42.71615m / (12.23456m * 12.23456m - 12.23456m), model.level3_nodes[2].value);
            //Assert.AreEqual((67.28380m + 92.71615m) / 12.23456m, model.level3_nodes[3].value);
            //Assert.AreEqual(17.28380m / 12.23456m, model.level3_nodes[4].value);
            //Assert.AreEqual(12.23456m / 23.45678m, model.level3_nodes[5].value);
            //Assert.AreEqual((67.28380m * 67.28380m) / (23.45678m * 23.45678m), model.level3_nodes[6].value);
            //Assert.AreEqual((117.28380m * 117.28380m) / (67.28380m * 67.28380m), model.level3_nodes[7].value);
            //Assert.AreEqual(3 / 12.23456m, model.level3_nodes[8].value);
            //Assert.AreEqual((117.28380m * 117.28380m) / (67.28380m * 67.28380m), model.level3_nodes[9].value);
            //Assert.AreEqual(3 / 12.23456m, model.level3_nodes[10].value);
            ////验证第2层的值
            //foreach (var node in model.level2_nodes)
            //    Assert.AreEqual(0, node.value);
            ////验证第1层的值
            //foreach (var node in model.level1_nodes)
            //    Assert.AreEqual(0, node.value);
        }