예제 #1
0
        public void CalcSquareTriangleEqual()
        {
            double square   = 6;
            var    triangle = new Triangle();

            triangle.CalcSquare(3, 4, 5);

            Assert.AreEqual(triangle.Square, square);
        }
예제 #2
0
        public void TestTriangleSquare()
        {
            int    i = 0;
            double sideA, sideB, sideC, square, halfPerimeter;

            while (i <= 10000)
            {
                sideA = random.NextDouble();
                sideB = random.NextDouble();
                sideC = random.NextDouble();
                Triangle triangle = new Triangle(sideA, sideB, sideC);
                halfPerimeter = (sideA + sideB + sideC) / 2;
                square        = Math.Sqrt(halfPerimeter * (halfPerimeter - sideA) * (halfPerimeter - sideB) * (halfPerimeter - sideC));
                Assert.AreEqual(square, triangle.CalcSquare());
                i++;
            }
        }