public void Run() { switch (_validator.ValidateArgs()) { case ArgsValidatorResult.Empty: ConsoleUI.ShowMessage(HELP); break; case ArgsValidatorResult.InvalidNumberOfArgs: ConsoleUI.ShowMessage(INVALID_NUMBER_OF_ARGS); break; case ArgsValidatorResult.InvalidTypeOfArgs: ConsoleUI.ShowMessage(INVALID_FORMAT); break; case ArgsValidatorResult.InvalidValue: ConsoleUI.ShowMessage(INVALID_SIZE); break; case ArgsValidatorResult.Success: FibonacciSequence sequence = GetSequence(); RunWithSequence(sequence); break; } }
public void FibonacciRedisCacheTest() { var cache = new FibonacciRedisCache("localhost"); var sequence = new FibonacciSequence(10, cache); foreach (var number in sequence) { Console.Write($"{number} "); } }
public void FibonacciMemoryCacheTest() { var cache = new FibonacciMemoryCache(); var first = new FibonacciSequence(5, cache); var second = new FibonacciSequence(10, cache); foreach (var number in first) { Console.Write($"{number} "); } foreach (var number in second) { Console.Write($"{number} "); } }
private void RunWithSequence(FibonacciSequence sequence) { var stringBuilder = new StringBuilder(); foreach (var i in sequence) { stringBuilder.AppendFormat("{0}, ", i); } if (stringBuilder.Length > 0) { stringBuilder.Length -= 2; ConsoleUI.ShowMessage(stringBuilder.ToString()); } else { ConsoleUI.ShowMessage(NO_FIBONACCI); } }