Esempio n. 1
0
        public void Division_is_the_same_as_multiplying_by_reciprocal(Rational x, NonZeroRational y)
        {
            var expected = x * y.Item.Invert();

            Assert.Equal(expected, x / y);
            Assert.Equal(expected, Rational.Divide(x, y));
        }
Esempio n. 2
0
        public void Multiplying_x_by_its_reciprocal_returns_1(NonZeroRational x)
        {
            var x_ = x.Item;

            Assert.Equal(Rational.One, x_ * x_.Invert());
            Assert.Equal(Rational.One, Rational.Multiply(x_, x_.Invert()));
        }
Esempio n. 3
0
        public void Dividing_3_values_is_the_same_as_dividing_by_the_product(Rational x, NonZeroRational y, NonZeroRational z)
        {
            Rational y_ = y, z_ = z;

            Assert.Equal(x / (y_ * z_), x / y_ / z_);
            Assert.Equal(Rational.Divide(x, Rational.Multiply(y_, z_)), Rational.Divide(Rational.Divide(x, y_), z_));
        }
Esempio n. 4
0
 public void Dividing_the_sum_is_the_same_as_dividing_each_and_then_adding_the_result(NonZeroRational x, Rational y, Rational z)
 {
     Assert.Equal((y + z) / x, (y / x) + (z / x));
     Assert.Equal(Rational.Divide(Rational.Add(y, z), x), Rational.Add(Rational.Divide(y, x), Rational.Divide(z, x)));
 }
Esempio n. 5
0
 public void Divide_by_itself_returns_1(NonZeroRational x)
 {
     Assert.Equal(Rational.One, x.Item / x);
     Assert.Equal(Rational.One, Rational.Divide(x, x));
 }