示例#1
0
		public void OperatorPlus_SameDenominator_ReturnsValidResult()
		{
			var a = new Fraction(3, 5);
			var b = new Fraction(1, 5);

			var actual = a + b;

			actual.Numerator.ShouldBeEquivalentTo(4);
			actual.Denominator.ShouldBeEquivalentTo(5);
		}
示例#2
0
		public void OperatorPlus_DifferentDenominator_ReturnsValidResult(int aNum, int aDenom, int bNum, int bDenom, int expectedNum, int expectedDenom)
		{
			var a = new Fraction(aNum, aDenom);
			var b = new Fraction(bNum, bDenom);
			var expected = new Fraction(expectedNum, expectedDenom);
			var actual = a + b;

			actual.ShouldBeEquivalentTo(expected);

		}
示例#3
0
		public static Fraction operator -(Fraction a, Fraction b)
		{
			var bChangedSign = new Fraction(-1 * b.Sign * b.Numerator, b.Denominator);
			return a + bChangedSign;
		}