예제 #1
0
        public void When_Number1_Is_Smaller_Than_Number2_Then_IsSmallerThan_Should_Return_True(
            double doubleNumber1, double doubleNumber2)
        {
            // Arrange
            var number1 = _calculator.FromDouble(doubleNumber1);
            var number2 = _calculator.FromDouble(doubleNumber2);

            // Act
            var comparison = _calculator.IsSmallerThan(number1, number2);

            // Assert
            comparison.Should().BeTrue();
        }
예제 #2
0
        public static bool AreClose <TAlgebraicNumber>(
            this IAlgebraicNumberCalculator <TAlgebraicNumber> calculator,
            TAlgebraicNumber number1,
            TAlgebraicNumber number2,
            TAlgebraicNumber tolerance)
        {
            if (calculator is null)
            {
                throw new ArgumentNullException(nameof(calculator));
            }

            var absoluteDifference = calculator.Abs(calculator.Subtract(number2, number1));

            return(calculator.IsSmallerThan(absoluteDifference, tolerance));
        }