static void Main(string[] args) { Console.WriteLine("Welcome, this program can calculate triangle perimeter and area"); while (true) { Console.WriteLine("Enter the side A, which value greater than zero"); var stringSideA = Console.ReadLine(); double.TryParse(stringSideA, out var sideA); Console.WriteLine("Enter the side B, which value greater than zero"); var stringSideB = Console.ReadLine(); double.TryParse(stringSideB, out var sideB); Console.WriteLine("Enter the side C, which value greater than zero"); var stringSideC = Console.ReadLine(); double.TryParse(stringSideC, out var sideC); try { var triangle = Triangles.CreateTriangle(sideA, sideB, sideC); var perimeter = triangle.FindPerimeter(); var area = triangle.FindArea(); Console.WriteLine($"Perimeter this triangle {perimeter}"); Console.WriteLine($"Area this triangle {area}"); } catch (ArgumentException ex) { Console.WriteLine(ex.Message); } } }
public void Should_ReturnException_When_CreateTriangleWithWrongSides() { // arrange var a = -5; var b = 0; var c = -8; Triangles.CreateTriangle(a, b, c); }
public void Should_ReturnRightArea_When_InputRightValueSides() { // arrange var a = 6; var b = 8; var c = 10; var triangle = Triangles.CreateTriangle(a, b, c); var expected = 24; // act var actual = triangle.FindArea(); // Assert Assert.AreEqual(expected, actual); }
public void Should_ReturnRightPerimeter_When_InputRightValueSides() { // arrange var a = 5; var b = 8; var c = 12; var triangle = Triangles.CreateTriangle(a, b, c); var expected = 25; // act var actual = triangle.FindPerimeter(); // Assert Assert.AreEqual(expected, actual); }