public void NegativeFibonacciNumberTest() { var firstIn = -8; var res = ReadifyFactory.GetFibonacciNumber(firstIn); Assert.AreEqual(-21, res); }
public void GetFibonacciNumberArgExceptionTest() { var firstIn = 100; var res = ReadifyFactory.GetFibonacciNumber(firstIn); Assert.AreEqual(93, res); }
public void PositiveFibonacciNumberTest() { var firstIn = 9; var res = ReadifyFactory.GetFibonacciNumber(firstIn); Assert.AreEqual(34, res); }
/// <summary> /// Calculating fibonacci number by received negative or positive index /// </summary> /// <param name="n">Negative or positive index</param> /// <exception cref="ArgumentOutOfRangeException">The incoming parameter should be between -92..92</exception> /// <returns>The fibonacci number</returns> public long FibonacciNumber(long n) { try { return(ReadifyFactory.GetFibonacciNumber(n)); } catch (ArgumentOutOfRangeException ex) { Trace.TraceWarning("Argument was out or range while invoking FibonacciNumber. n: {0}, Error: {1}", n, ex); throw new FaultException <ArgumentOutOfRangeException>(ex, ex.Message); } catch (Exception ex) { Trace.TraceError("Error invoking FibonacciNumber. n: {0}, Error: {1}", n, ex); throw new FaultException("Sorry, there happened something unexpected!!!"); } }