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))); }
public void TriangleRectangle_SidesAreZeroAndNegative_ThrowsArgumentException() { Assert.ThrowsException <ArgumentException>( () => TriangleHelpers.IsRectangular(-1, 0, 5), "Sides must be positive"); }
public void TriangleRectangular_ResultFalse() { Assert.IsFalse(TriangleHelpers.IsRectangular(3, 4, 4)); }