Exemplo n.º 1
0
        public void Test_rebuild_cylinder()
        {
            cylinder test = new cylinder();

            float[,] t = new float[3, 3];
            test.cylinder_build(-1, 0, 0, 0, 1, 2, 4, ref t);
            test.cylinder_build(0, 0, 0, 0, 2, 2, 4, ref t);
            bool flag = true;

            cylinder.cylinder_pr res = (cylinder.cylinder_pr)test.cylinders[0];
            for (int i = 0; i < res.base_cylinder_x.Count; i++)
            {
                res.base_cylinder_x[i] = Math.Round((float)res.base_cylinder_x[i] * 10) / 10;
            }
            for (int i = 0; i < res.base_cylinder_z.Count; i++)
            {
                res.base_cylinder_z[i] = Math.Round((float)res.base_cylinder_z[i] * 10) / 10;
            }
            int r = res.base_cylinder_x.IndexOf(2.0);
            int l = res.base_cylinder_x.IndexOf(-2.0);
            int u = res.base_cylinder_z.IndexOf(2.0);
            int d = res.base_cylinder_z.IndexOf(-2.0);

            if (r < 0 || !Convert.Equals(res.base_cylinder_z[r], 0.0))
            {
                flag = false;
            }
            if (l < 0 || !Convert.Equals(res.base_cylinder_z[l], 0.0))
            {
                flag = false;
            }
            if (u < 0 || !Convert.Equals(res.base_cylinder_x[u], 0.0))
            {
                flag = false;
            }
            if (d < 0 || !Convert.Equals(res.base_cylinder_x[d], 0.0))
            {
                flag = false;
            }

            Assert.AreEqual(true, flag);
        }
Exemplo n.º 2
0
        public void Test_change_color()
        {
            cylinder test = new cylinder();

            float[,] colors = new float[3, 3];
            colors[0, 0]    = 1.0f; colors[0, 1] = 0.0f; colors[0, 2] = 0.0f;
            colors[1, 0]    = 1.0f; colors[1, 1] = 0.0f; colors[1, 2] = 0.0f;
            colors[2, 0]    = 1.0f; colors[2, 1] = 0.0f; colors[2, 2] = 0.0f;
            test.cylinder_build(-1, 0, 0, 0, 1, 3, 100, ref colors);
            test.cylinder_build(-1, 3, 0, 0, 2, 4, 100, ref colors);
            test.change_color(0, 0, 0.0f, 0.0f, 1.0f);
            test.change_color(1, 1, 0.0f, 1.0f, 0.0f);
            bool flag = true;

            cylinder.cylinder_pr res1 = (cylinder.cylinder_pr)test.cylinders[0];
            cylinder.cylinder_pr res2 = (cylinder.cylinder_pr)test.cylinders[1];
            if (res1.cylinder_colors[0, 0] != 0.0)
            {
                flag = false;
            }
            if (res1.cylinder_colors[0, 1] != 0.0)
            {
                flag = false;
            }
            if (res1.cylinder_colors[0, 2] != 1.0)
            {
                flag = false;
            }

            if (res1.cylinder_colors[1, 0] != 1.0)
            {
                flag = false;
            }
            if (res1.cylinder_colors[1, 1] != 0.0)
            {
                flag = false;
            }
            if (res1.cylinder_colors[1, 2] != 0.0)
            {
                flag = false;
            }

            if (res1.cylinder_colors[2, 0] != 1.0)
            {
                flag = false;
            }
            if (res1.cylinder_colors[2, 1] != 0.0)
            {
                flag = false;
            }
            if (res1.cylinder_colors[2, 2] != 0.0)
            {
                flag = false;
            }

            if (res2.cylinder_colors[0, 0] != 1.0)
            {
                flag = false;
            }
            if (res2.cylinder_colors[0, 1] != 0.0)
            {
                flag = false;
            }
            if (res2.cylinder_colors[0, 2] != 0.0)
            {
                flag = false;
            }

            if (res2.cylinder_colors[1, 0] != 0.0)
            {
                flag = false;
            }
            if (res2.cylinder_colors[1, 1] != 1.0)
            {
                flag = false;
            }
            if (res2.cylinder_colors[1, 2] != 0.0)
            {
                flag = false;
            }

            if (res2.cylinder_colors[2, 0] != 1.0)
            {
                flag = false;
            }
            if (res2.cylinder_colors[2, 1] != 0.0)
            {
                flag = false;
            }
            if (res2.cylinder_colors[2, 2] != 0.0)
            {
                flag = false;
            }

            Assert.AreEqual(true, flag);
        }