public void TestComputeSequenceWithNumber3Test() { INumericCalculator calculator = new OddNumericSequenceCalculator(); List<string> result = (List<string>)calculator.ComputeSequenceWithNumber(0); List<string> expected = new List<string> { }; CollectionAssert.AreEqual(expected, result); }
/// <summary> /// This factory is made to use the NumericSequenceCalculator associated with the enum NumericCalculatorType. /// </summary> /// <param name="calculatorType">The type of calculator which will be used to compute the sequence</param> /// <param name="number">The maximum number of the sequence</param> /// <returns>A collection of numbers as string collection containing the sequence, or null /// if the NumericCalculatorType haven't a class associated with it.</returns> public static ICollection<string> ComputeSequenceWithNumber(NumericCalculatorType calculatorType,int number) { INumericCalculator calculator = null; switch (calculatorType) { case NumericCalculatorType.Normal: calculator = new NormalNumericSequenceCalculator(); break; case NumericCalculatorType.Fibonacci: calculator = new FibonacciNumericSequenceCalculator(); break; case NumericCalculatorType.Even: calculator = new EvenNumericSequenceCalculator(); break; case NumericCalculatorType.Odd: calculator = new OddNumericSequenceCalculator(); break; case NumericCalculatorType.Special: calculator = new SpecialNumericSequenceCalculator(); break; default: break; } if(calculator != null) { return calculator.ComputeSequenceWithNumber(number); } else { return null; } }
public void ComputeSequenceWithNumber1Test() { INumericCalculator calculator = new OddNumericSequenceCalculator(); List<string> result = (List<string>)calculator.ComputeSequenceWithNumber(15); List<string> expected = new List<string> { "1", "3", "5", "7", "9", "11", "13", "15" }; CollectionAssert.AreEqual(expected, result); }