Exemple #1
0
        public static double GetArea(double a, double b, double c)
        {
            if (!TriangleHelpers.IsTriangleValid(a, b, c))
            {
                throw new ArgumentException("Sides must be positive");
            }

            var halfPerimeter = (a + b + c) / 2;

            return(Math.Sqrt(halfPerimeter * (halfPerimeter - a) * (halfPerimeter - b) * (halfPerimeter - c)));
        }
Exemple #2
0
 public void TriangleRectangle_SidesAreZeroAndNegative_ThrowsArgumentException()
 {
     Assert.ThrowsException <ArgumentException>(
         () => TriangleHelpers.IsRectangular(-1, 0, 5),
         "Sides must be positive");
 }
Exemple #3
0
 public void TriangleRectangular_ResultFalse()
 {
     Assert.IsFalse(TriangleHelpers.IsRectangular(3, 4, 4));
 }