public void MultiplyFractionsTest(int leftNum, int leftDen, int rightNum, int rightDen, int resNum, int resDen)
        {
            var left = new Fraction(leftNum, leftDen);

            var right = new Fraction(rightNum, rightDen);

            var result = FractionCalculator.Multiply(left, right);

            Assert.Equal(resNum, result.Numerator);
            Assert.Equal(resDen, result.Denominator);
        }
Beispiel #2
0
 public void Should_multiply_zero_fractions()
 {
     Assert.That(FractionCalculator.Multiply(new Fraction(0, 0), new Fraction(0, 0)),
                 Is.EqualTo(new Fraction(0, 0)));
 }
Beispiel #3
0
 public void Should_multiply_negative_fractions(int multiplicandNumerator, int multiplicandDenominator, int multiplierNumerator, int multiplierDenominator, int expectedNumerator, int expectedDenominator)
 {
     Assert.That(FractionCalculator.Multiply(new Fraction(multiplicandNumerator, multiplicandDenominator), new Fraction(multiplierNumerator, multiplierDenominator)),
                 Is.EqualTo(new Fraction(expectedNumerator, expectedDenominator)));
 }
Beispiel #4
0
 public void Should_return_a_zero_fraction_when_one_factor_is_zero(int multiplicandNumerator, int multiplicandDenominator, int multiplierNumerator, int multiplierDenominator, int expectedNumerator, int expectedDenominator)
 {
     Assert.That(FractionCalculator.Multiply(new Fraction(multiplicandNumerator, multiplicandDenominator), new Fraction(multiplierNumerator, multiplierDenominator)),
                 Is.EqualTo(new Fraction(expectedNumerator, expectedDenominator)));
 }
Beispiel #5
0
 public void Should_multiply_fractions_with_different_denominator()
 {
     Assert.That(FractionCalculator.Multiply(new Fraction(1, 4), new Fraction(2, 5)),
                 Is.EqualTo(new Fraction(1, 10)));
 }
Beispiel #6
0
 public void Should_multiply_fractions_with_same_denominator()
 {
     Assert.That(FractionCalculator.Multiply(new Fraction(1, 4), new Fraction(2, 4)),
                 Is.EqualTo(new Fraction(1, 8)));
 }
Beispiel #7
0
 public void Should_multiply_negative_whole_numbers(int multiplicandNumerator, int multiplierNumerator, int expectedNumerator)
 {
     Assert.That(FractionCalculator.Multiply(new Fraction(multiplicandNumerator), new Fraction(multiplierNumerator)),
                 Is.EqualTo(new Fraction(expectedNumerator)));
 }