示例#1
0
        public void On0Returns1()
        {
            var mathLib = new FunctionalFactorial();
            var result  = mathLib.Factorial(0);

            Assert.Equal(1, result);
        }
示例#2
0
        public void On13Returns6227020800()
        {
            var mathLib = new FunctionalFactorial();
            var result  = mathLib.Factorial(13);

            Assert.Equal(6227020800, result);
        }
示例#3
0
        public void On10Returns3628800()
        {
            var mathLib = new FunctionalFactorial();
            var result  = mathLib.Factorial(10);

            Assert.Equal(3628800, result);
        }
示例#4
0
        public void On3Returns6()
        {
            var mathLib = new FunctionalFactorial();
            var result  = mathLib.Factorial(3);

            Assert.Equal(6, result);
        }
示例#5
0
        public void One2Returns2()
        {
            var mathLib = new FunctionalFactorial();
            var result  = mathLib.Factorial(2);

            Assert.Equal(2, result);
        }
示例#6
0
        public IMathLib GetMathLib(FactorialAlgorithm factorialAlgorithm)
        {
            IFactorialStrategy strategy;

            switch (factorialAlgorithm)
            {
            case FactorialAlgorithm.Functional:
                strategy = new FunctionalFactorial();
                break;

            case FactorialAlgorithm.Recursional:
                strategy = new RecursiveFactorial();
                break;

            default:
                throw new NotSupportedException(string.Format(Resources.Err_FactorialAlgorithmNotSupported, factorialAlgorithm));
            }
            return(new MathLib(strategy));
        }
示例#7
0
 public void OnMinus1ThrowsException()
 {
     var mathLib   = new FunctionalFactorial();
     var exception = Assert.Throws <ArgumentException>(() => mathLib.Factorial(-1));
 }