public void FibonacciTest() { var fab = new Fibonacci(); Assert.AreEqual(0, fab.Calculate(0), "Failed to calcluate Fab 0"); Assert.AreEqual(1, fab.Calculate(1), "Failed to calcluate Fab 1"); Assert.AreEqual(55, fab.Calculate(10), "Failed to calcluate Fab 10"); Assert.AreEqual(6765, fab.Calculate(20), "Failed to calcluate Fab 20"); }
public void Fibonacci_SpecialValuesShouldReturnMinusOne(int n) { BigInteger expected = -1; BigInteger actual = Fibonacci.Calculate(n); Assert.Equal(expected, actual); }
public void Fibonacci_BigValuesShouldCalculate() { BigInteger expected = BigInteger.Parse("354224848179261915075"); BigInteger actual = Fibonacci.Calculate(100); Assert.Equal(expected, actual); }
public void Fibonacci_TestBaseCases() { Assert.AreEqual(new BigInteger(1), Fibonacci.Calculate(1)); Assert.AreEqual(new BigInteger(1), Fibonacci.Calculate(2)); Assert.AreEqual(new BigInteger(2), Fibonacci.Calculate(3)); Assert.AreEqual(new BigInteger(3), Fibonacci.Calculate(4)); Assert.AreEqual(new BigInteger(5), Fibonacci.Calculate(5)); }
public void When_I_Call_GetNElements() { const int size = 5; var elements = Fibonacci.GetFirstNElements(size); Assert.That(elements.Count, Is.EqualTo(5)); Assert.IsTrue(elements.Any(element => element.Equals(Fibonacci.Calculate(elements.IndexOf(element))))); }
private void btnCalculate_Click(object sender, EventArgs e) { //converts text into integer int Input = Convert.ToInt16(txtInput.Text); txtInput.Text = txtInput.Text + Term.Correct(Input); txtAnswer.Text = Convert.ToString(Fibonacci.Calculate(Input)); }
public void Calculate_ShouldReturnXPosWhereFunctionResultIsMinimum() { var functionHandler = new SingleVarFunc("2 * x ^ 2 - 12 * x"); var fibonacci = new Fibonacci(new Interval(0, 10), 0.01, 1, functionHandler); var result = Math.Round(fibonacci.Calculate() * 10000) / 10000; Assert.AreEqual(2.6923, result); }
public void Fibonacci_GetSixthElement() { //Arrange //Act var result = Fibonacci.Calculate(6); //Assert Assert.AreEqual(8, result); }
public void Fibonacci_GetFourthElement() { //Arrange //Act var result = Fibonacci.Calculate(4); //Assert Assert.AreEqual(3, result); }
public void Fibonacci_GetThirdElement() { //Arrange //Act var result = Fibonacci.Calculate(3); //Assert Assert.AreEqual(2, result); }
public void Fibonacci_GetZeroElement() { //Arrange //Act var result = Fibonacci.Calculate(0); //Assert Assert.AreEqual(0, result); }
public void Fibonacci_GetSecondElement() { //Arrange //Act var result = Fibonacci.Calculate(2); //Assert Assert.AreEqual(1, result); }
//Next button click private void btnNext_Click(object sender, EventArgs e) { string strText = txtInput.Text; strText = strText.Remove(strText.Length - 1); strText = strText.Remove(strText.Length - 1); int Input = Convert.ToInt16(strText); Input = Input + 1; txtInput.Text = Input + Term.Correct(Input); txtAnswer.Text = Convert.ToString(Fibonacci.Calculate(Input)); }
public void Fibonacci_GetCollectionOfFibonaccy() { //Arrange var criteria = new Dictionary <int, double>(); for (var i = 0; i < 10; i++) { criteria[i] = Fibonacci.Calculate(i); } //Act var result = new Dictionary <int, double>().FibonacciSequence(9); //Assert CollectionAssert.AreEqual(criteria, result); }
public void Test() { Assert.Equal(0, Fibonacci.Calculate(0)); Assert.Equal(1, Fibonacci.Calculate(1)); Assert.Equal(1, Fibonacci.Calculate(2)); Assert.Equal(2, Fibonacci.Calculate(3)); Assert.Equal(3, Fibonacci.Calculate(4)); Assert.Equal(5, Fibonacci.Calculate(5)); Assert.Equal(8, Fibonacci.Calculate(6)); Assert.Equal(13, Fibonacci.Calculate(7)); Assert.Equal(21, Fibonacci.Calculate(8)); Assert.Equal(34, Fibonacci.Calculate(9)); Assert.Equal(55, Fibonacci.Calculate(10)); Fibonacci.Calculate(1000); }
//Previous button click event private void btnPrevious_Click(object sender, EventArgs e) { //Determines the proper suffix of the number string strText = txtInput.Text; strText = strText.Remove(strText.Length - 1); strText = strText.Remove(strText.Length - 1); int Input = Convert.ToInt16(strText); Input = Input - 1; txtInput.Text = Input + Term.Correct(Input); txtAnswer.Text = Convert.ToString(Fibonacci.Calculate(Input)); }
static void Main(string[] args) { Fibonacci fibonacci2 = new Fibonacci(2); Fibonacci fibonacci4 = new Fibonacci(4); Fibonacci fibonacci8 = new Fibonacci(8); Fibonacci fibonacci16 = new Fibonacci(16); Task task1 = new Task(() => { Console.WriteLine(($"The 2nd Fibonacci number is {fibonacci2.Calculate()}")); }); Task task2 = new Task(() => { Console.WriteLine(($"The 4th Fibonacci number is {fibonacci4.Calculate()}")); }); Task task3 = new Task(() => { Console.WriteLine(($"The 8th Fibonacci number is {fibonacci8.Calculate()}")); }); Task task4 = new Task(() => { Console.WriteLine($"The 16th Fibonacci number is {fibonacci16.Calculate()}"); }); task1.Start(); task1.Wait(); task2.Start(); task2.Wait(); task3.Start(); task3.Wait(); task4.Start(); task4.Wait(); foreach (int element in Fibonacci.cache) { Console.WriteLine(element); } }
public void FibonacciOfNegativeNumberDoesNotExist() { Fibonacci.Calculate(-1); }
public void FibonacciOfNumberGreaterThanOne() { Assert.AreEqual(Fibonacci.Calculate(6), 8); }
public void Fibonacci_TestExceedIntMax() { Assert.AreEqual(new BigInteger(2971215073L), Fibonacci.Calculate(47)); }
public void Fibonacci_TestLessThan1() { Assert.AreEqual(new BigInteger(-1), Fibonacci.Calculate(0)); Assert.AreEqual(new BigInteger(-1), Fibonacci.Calculate(-1)); }
public void Fibonacci_SimpleValuesShouldCalculate(int n, BigInteger expected) { BigInteger actual = Fibonacci.Calculate(n); Assert.Equal(expected, actual); }
public void Fibonacci_of_number_greater_than_one() { int result = Fibonacci.Calculate(6); Assert.AreEqual(8, result); }
public void When_I_Call_Calculate() { Assert.That(Fibonacci.Calculate(5), Is.EqualTo(5)); }
public void Fibonacci_TestMoreThan2000() { Assert.AreEqual(new BigInteger(-1), Fibonacci.Calculate(2001)); }
public List <long> GetFibonacci(FibonacciModel model) { Fibonacci fibonacci = new Fibonacci(); return(fibonacci.Calculate(model.Length)); }
public void LowerBoundsTest(int x, int expectedFibonacciNumber) { Assert.AreEqual(Fibonacci.Calculate(x), expectedFibonacciNumber); }
public void FibonacciCorrect(uint number, uint correct) { Assert.Equal(correct, Fibonacci.Calculate(number)); }
public void Fibonacci_TestExceedLongMax() { Assert.AreEqual(new BigInteger(12200160415121876738UL), Fibonacci.Calculate(93)); }