コード例 #1
0
        public void ContinuedFractionsShouldReturnValueAsZeroIfDenominatorIsBiggerThanNumerator(int numerator, int denominator)
        {
            ContinuedFractions cf = new ContinuedFractions();

            (int, int, int)value = cf.findNext(numerator, denominator);
            Assert.Equal(0, value.Item1);
        }
コード例 #2
0
        public void ContinuedFractionsShouldReturnValueAsNumeratorIfDenominatorIsOne(int numerator, int denominator)
        {
            ContinuedFractions cf = new ContinuedFractions();

            (int, int, int)value = cf.findNext(numerator, denominator);
            Assert.Equal((numerator, 0, 0), value);
        }
コード例 #3
0
        public void ContinuedFractionsShouldReturnValueOfZeroToNumeratorAndNewValuesAsZero(int numerator, int denominator)
        {
            ContinuedFractions cf = new ContinuedFractions();

            (int, int, int)value = cf.findNext(numerator, denominator);
            Assert.Equal((0, 0, 0), value);
        }
コード例 #4
0
        public void ContinuedFractionsShouldThrowErrorWhenDenominatorIsZeroOrLess(int numerator, int denominator)
        {
            ContinuedFractions cf  = new ContinuedFractions();
            Action             act = () => cf.findNext(numerator, denominator);

            Assert.Throws <ArgumentException>(act);
        }
コード例 #5
0
        public void ContinuedFractionsShouldReturnCorrectNextValues(int numerator, int denominator)
        {
            ContinuedFractions cf = new ContinuedFractions();

            (int, int, int)value = cf.findNext(numerator, denominator);
            int gcd = new GreatestCommonDenominator().findGCD(denominator, numerator % denominator);

            Assert.Equal((numerator / denominator, denominator / gcd, (numerator % denominator) / gcd), value);
        }
コード例 #6
0
 public Factoriser()
 {
     gcd = new GreatestCommonDenominator();
     cf  = new ContinuedFractions();
 }