示例#1
0
        public TriangularViewModel()
        {
            this.PyramidData = new List <TriangularModel>();

            PyramidData.Add(new TriangularModel()
            {
                Category = "License", Percentage = 15d
            });
            PyramidData.Add(new TriangularModel()
            {
                Category = "Other", Percentage = 18d
            });
            PyramidData.Add(new TriangularModel()
            {
                Category = "Sales", Percentage = 14d
            });
            PyramidData.Add(new TriangularModel()
            {
                Category = "Income", Percentage = 16d
            });
            PyramidData.Add(new TriangularModel()
            {
                Category = "Production", Percentage = 14d
            });
        }
        public void MaxSumTest()
        {
            var lines   = PyramidData.TestData3Lines();
            var pyramid = InputData.CreatePyramid(lines);
            var ret     = _calculator.GetMaxSum(pyramid);

            Assert.AreNotEqual(ret, 22, 0, "Should not go to left child");
            Assert.AreNotEqual(ret, 18, 0, "Should not to the smaller value");
            Assert.IsTrue(ret == 20, "Wrong result");

            lines   = PyramidData.TestData4Lines();
            pyramid = InputData.CreatePyramid(lines);
            ret     = _calculator.GetMaxSum(pyramid);
            Assert.IsTrue(ret == 16, "Wrong result");
            pyramid[3, 0] = 8; // 4 -->8
            ret           = _calculator.GetMaxSum(pyramid);
            Assert.IsTrue(ret == 18, "Should change the route");

            pyramid[2, 0] = 0; pyramid[2, 1] = 0; pyramid[2, 2] = 0;
            ret           = _calculator.GetMaxSum(pyramid);
            Assert.IsTrue(ret == 0, "Unable to reach the bottom");
            pyramid[2, 0] = 2; pyramid[2, 1] = 4; pyramid[2, 2] = 6;
            ret           = _calculator.GetMaxSum(pyramid);
            Assert.IsTrue(ret == 0, "Unable to reach the bottom due to invalid line");

            lines   = PyramidData.TestData5Lines();
            pyramid = InputData.CreatePyramid(lines);
            ret     = _calculator.GetMaxSum(pyramid);
            Assert.IsTrue(ret == 23, "Should change the previous route");
            pyramid[4, 2] = 7; // 3 -->7
            ret           = _calculator.GetMaxSum(pyramid);
            Assert.IsTrue(ret == 23, "Case: two valid path. Should not change the result");
        }
示例#3
0
 void OnEnable()
 {
     stats        = this.gameObject.GetComponent <PyramidData>();
     pyramidBase  = gameObject.transform.GetChild(0).gameObject;
     pyramidTop   = gameObject.transform.GetChild(1).gameObject;
     baseRenderer = pyramidBase.GetComponent <MeshRenderer>();
     topRenderer  = pyramidTop.GetComponent <MeshRenderer>();
 }
示例#4
0
        public void CheckEmptyFile()
        {
            string filePath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
                                                            ConfigurationManager.AppSettings["relativeFilePath"].ToString() + "EmptyFileTest.txt"));
            PyramidData pyramidData = new PyramidData(filePath);

            Assert.AreEqual(0, pyramidData.ReadByLines().ToList().Count);
        }
        public void CheckIfFileExists()
        {
            PyramidData pyramidData = new PyramidData();

            pyramidData.ReadByLines().ToList();
        }
示例#6
0
        public void CheckInitialization()
        {
            PyramidData pyramidData = new PyramidData(null);

            pyramidData.ReadByLines().ToList();
        }