public void ShouldReturnTheFactorialWebServiceResult() { _factorialWebService.Stub(s => s.GetFactorialFor( "https://murmuring-ravine-8545.herokuapp.com/?n=1000")) .Return("very big number"); var actualResult = _factorialCalculator.Calculate(1000); Assert.AreEqual("very big number", actualResult); }
private void FactorialOf(int number, int shouldBe) { var actualFactorial = _factorialCalculator.Calculate(number); var expectedFactorial = shouldBe; Assert.AreEqual(expectedFactorial, actualFactorial); }
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 TestFactorialOutsideLimit() { FactorialCalculator facCal = new FactorialCalculator(); var exception = Assert.Throws <System.NotSupportedException>(() => facCal.Calculate(11)); Assert.That(exception.Message, Is.EqualTo("n > 10 is not supported")); }
static void Main(string[] args) { var random = new System.Random(); var calculator = new FactorialCalculator(); while (true) { var value = random.Next(1, 10); var result = calculator.Calculate(value); Console.WriteLine($"Faktoriál hodnoty {value} je {result}!"); } }
static void Main(string[] args) { string line = null; var calculator = new FactorialCalculator(); do { if (Int32.TryParse(line, out var value)) { var result = calculator.Calculate(value); Console.WriteLine($"Faktoriál hodnoty {value} je {result}!"); } Console.WriteLine($"Zadejte hodnotu pro výpočet faktoriálu:"); line = Console.ReadLine(); } while (line.ToLower() != "y"); }
public IActionResult GetFactorial(int n) => Ok(new CalculationResponse(_factorialCalculator.Calculate(n)));
public void Test_less_than_10(int input, int output) { int result = factorialCalculator.Calculate(input); Assert.AreEqual(output, result); }
public int TestFactorialInLimit(int number) { FactorialCalculator facCal = new FactorialCalculator(); return(facCal.Calculate(number)); }