public void Should_VisitorIsConfirmedBeTrue_When_TriangleAcceptVisitorTheoremBackPythagorean() { var a = 3d; var b = 4d; var c = 5d; var triangle = _figureFactoryfactory.CreateTriangle(a, b, c); var pythagoreanTheorem = new VisitorTheoremBackPythagorean(1e-2); triangle.Accept(pythagoreanTheorem); Assert.IsTrue(pythagoreanTheorem.IsConfirmed); }
public void Should_ReturnSameAreaWithGivenPrecision_When_TriangleGetAreaInvoked(double precision) { var a = _fixture.Create <double>(); var b = _fixture.Create <double>(); var c = (a + b) * 0.7; // a + b < c var p = (a + b + c) / 2d; var triangle = _figureFactoryfactory.CreateTriangle(a, b, c); var expected = Math.Sqrt(p * (p - a) * (p - b) * (p - c)); var result = triangle.GetArea(); var diff = expected - result; diff = diff * diff; Assert.IsTrue(diff <= precision); }
public void Should_CreateTriangleInstance_When_TriangleFactoryCreateTriangle() { var result = _figureFactoryfactory.CreateTriangle(It.IsAny <double>(), It.IsAny <double>(), It.IsAny <double>()); Assert.IsInstanceOfType(result, typeof(Triangle)); }
public void CreateTriangle_NormalEdges_Created(double a, double b, double c) { var triangle = _factory.CreateTriangle(a, b, c); triangle.As <Triangle>().Should().NotBeNull(); }