public void ValidAreaCalculation() { Triangle tr1 = new Triangle(3, 4, 5); Triangle tr2 = new Triangle(2, 3, 3); Circle c1 = new Circle(22); Circle c2 = new Circle(11); IAreaCalculatable[] figures = { tr1, tr2, c1, c2 }; List <double> result = new List <double>(); List <double> expected = new List <double> { 6, 2.828, 1520.53, 380.132 }; foreach (var figure in figures) { result.Add(AreaCalculator.GetArea(figure)); } double prec = 0.01; for (int i = 0; i < expected.Count; i++) { Assert.AreEqual(expected[i], result[i], prec, "Wrong Answer!"); } }
public void CalculateArea_SomeValues_MatchResult(double radius, double expected) { var circle = _factory.CreateCircle(radius); var area = _calc.GetArea(circle); area.Should().BeApproximately(expected, 1e-10); }
public void CalculateArea_SomeValues_MatchResult(double a, double b, double c, double expected) { var triangle = _factory.CreateTriangle(a, b, c); var area = _calc.GetArea(triangle); area.Should().BeApproximately(expected, 1e-10); }
static void Main(string[] args) { Triangle tr1 = new Triangle(3, 4, 5); Triangle tr2 = new Triangle(2, 3, 3); Circle c1 = new Circle(22); Circle c2 = new Circle(11); IAreaCalculatable i1 = tr1; IAreaCalculatable i2 = tr2; IAreaCalculatable i3 = c1; IAreaCalculatable i4 = c2; double a1 = AreaCalculator.GetArea(i1); double a2 = AreaCalculator.GetArea(i2); double a3 = AreaCalculator.GetArea(i3); double a4 = AreaCalculator.GetArea(i4); }