public void FibonacciOfTwentyTestMethod() { var actual = FibonacciManager.Calculate(20); var expected = 6765; Assert.AreEqual(expected, actual); }
public void FibonacciOfOneTestMethod() { var actual = FibonacciManager.Calculate(1); var expected = 1; Assert.AreEqual(expected, actual); }
public void FibonacciNegativeNumbersTestMethod() { long[] values = { -8, -7, -6, -5, -4, -3, -2, -1 }; long[] expected = { -21, 13, -8, 5, -3, 2, -1, 1 }; for (byte index = 0; index < values.Length; index++) { Assert.AreEqual(FibonacciManager.Calculate(values[index]), expected[index]); } }
public FibonacciNumberResponse FibonacciNumber(FibonacciNumberRequest request) { if (request == null) { throw new FaultException <ArgumentNullException>(new ArgumentNullException("request"), "null arguments are invalid"); } try { var result = new FibonacciNumberResponse(FibonacciManager.Calculate(request.n)); return(result); } catch (ArgumentOutOfRangeException exp) { throw new FaultException <ArgumentOutOfRangeException>(exp, exp.Message); } catch (Exception ex) { throw new FaultException(ex.Message); } }
public async Task <FibonacciNumberResponse> FibonacciNumberAsync(FibonacciNumberRequest request) { if (request == null) { throw new FaultException <ArgumentNullException>(new ArgumentNullException("request"), "null arguments are invalid"); } return(await Task.Run <FibonacciNumberResponse>(() => { try { var result = new FibonacciNumberResponse(FibonacciManager.Calculate(request.n)); return result; } catch (ArgumentOutOfRangeException exp) { throw new FaultException <ArgumentOutOfRangeException>(exp, exp.Message); } catch (Exception ex) { throw new FaultException(ex.Message); } })); }