/// <summary> /// Entry point for program. /// This method will take argument from user and call another method to calculate factorial of the given number. /// </summary> static void Main() { try { // Flag used to continue program execution based on the user inputs bool flag = true; while (flag) { Console.WriteLine(InputMessage); string number = Console.ReadLine(); Factorial objFactorial = new Factorial(); string result = objFactorial.CalculateFactorial(number); Console.WriteLine(string.Format("{0}{1}{2}{3}", FactorialMessage, number, Is, result)); Console.WriteLine(DisplayMessageOne); Console.WriteLine(DisplayMessageTwo); if (Yes != Console.ReadLine()) { flag = false; } } } catch (Exception exception) { Console.WriteLine(string.Format("{0}{1}", Error, exception.Message)); Console.ReadLine(); } }
public void FactorialOfNegativeNumberTest() { Factorial objFactorial = new Factorial(); string actual = objFactorial.CalculateFactorial(NegativeNumber); Assert.AreEqual(InvalidNumberMessage, actual); }
public void FactorialOfHundred() { Factorial objFactorial = new Factorial(); string actual = objFactorial.CalculateFactorial(Hundred); Assert.AreEqual(FactOfHundred, actual); }
public void FactorialOfFive() { Factorial objFactorial = new Factorial(); string actual = objFactorial.CalculateFactorial(FiveNumber); Assert.AreEqual(FactOfFive, actual); }
public void FactorialOfEmptyNumberTest() { Factorial objFactorial = new Factorial(); string actual = objFactorial.CalculateFactorial(string.Empty); Assert.AreEqual(EmptyStringMessage, actual); }
public void FactorialOfZero() { Factorial objFactorial = new Factorial(); string actual = objFactorial.CalculateFactorial(ZeroNumber); Assert.AreEqual(OneNumber, actual); }