public void TestCalculateFactorial(int n, int expectedFactorial) { var factorialCalculator = new FactorialCalculator(); var actualFactorial = factorialCalculator.Factorial(n); Assert.AreEqual(expectedFactorial, actualFactorial); }
public void FactorialTest() { var fac = new FactorialCalculator(); // var result1 = fac.Factorial(3); // Console.WriteLine(result1); var result2 = fac.Factorial(10); Console.WriteLine(result2); }
private static double GetNumberOfCombinations(int objectsCount, int objectsCountInCombination) { var diff = objectsCount - objectsCountInCombination; if (diff == 0) { return(1); } var divident = FactorialCalculator.Factorial(objectsCount); var divisor = FactorialCalculator.Factorial(objectsCountInCombination) * FactorialCalculator.Factorial(diff); var numberOfCombinations = divident / divisor; return(numberOfCombinations); }
public void TestFactorial() { var calculator = new FactorialCalculator(); var expected = Enumerable.Range(1, 10).Select(i => new { i, r = calculator.Factorial(i) }).ToDictionary(key => key.i, value => value.r); foreach (var pair in expected) { Assert.AreEqual(pair.Value, calculator.Calculate(pair.Key).Match(x => x, x => x.Value)); } foreach (var pair in expected) { Assert.AreEqual(pair.Value, calculator.Calculate(pair.Key).Match(x => x, x => x.Value)); } }
public void Returns_Factorial(int value, int expectedFactorial) { var calculatedFactorial = _calculator.Factorial(value); Assert.AreEqual(expectedFactorial, calculatedFactorial); }