Beispiel #1
0
        public void GetFibonacci_ShouldReturnRequestedNandNTHinSequence()
        {
            // Arrange
            FibonacciController fc = new FibonacciController();

            //Act
            FibonacciStruct result = fc.GetFibonacci((uint)12);

            // Assert
            Assert.AreEqual(result.numberRequested, (uint)12);
            Assert.AreEqual(result.nthNumberOfFibonacciSequence, (uint)144);
        }
Beispiel #2
0
        public FibonacciStruct GetFibonacci(uint n)
        {
            log.Debug("GetFibonacci - Requested value is: " + n.ToString());

            Fibonacci       f        = new Fibonacci();
            FibonacciStruct fbResult = new FibonacciStruct();

            try
            {
                fbResult = f.GetNthFibonacciNumberIterative(n);
            }
            catch (Exception)
            {
                HttpResponseMessage response =
                    this.Request.CreateResponse(HttpStatusCode.InternalServerError, "Unspecified error.");
                log.Fatal(response.ToString());
                throw new HttpResponseException(response);
            }

            log.Debug("GetFibonacci - Response is the value requested: " + fbResult.numberRequested.ToString());
            log.Debug("GetFibonacci - Response is nth value in sequence: " + fbResult.nthNumberOfFibonacciSequence.ToString());

            return(fbResult);
        }