public void FunctionalLifeSpanTest_ShouldProduceDesiredResults() { // Arrange. var firstTerm = new BigInteger(3); var secondTerm = new BigInteger(3); // Act. var target = new FibonacciSequence(firstTerm, secondTerm); // Assert. target.CalculatedTermCount.Should().Be(2); target[0].Should().Be(firstTerm); target[1].Should().Be(secondTerm); target[2].Should().Be(6); target[3].Should().Be(9); target[4].Should().Be(15); target.CalculatedTermCount.Should().Be(5); target[5].Should().Be(24); target[6].Should().Be(39); target[7].Should().Be(63); target[8].Should().Be(102); target[9].Should().Be(165); target.CalculatedTermCount.Should().Be(10); target.Reset(); target.CalculatedTermCount.Should().Be(2); target[0].Should().Be(firstTerm); target[1].Should().Be(secondTerm); target[2].Should().Be(6); }
public void FibonacciSequence_ResetTests(int count, int k, long[] expected) { var sequence = new FibonacciSequence(count); while (sequence.MoveNext()) { } sequence.Reset(); for (int i = 0; i < k; i++) { sequence.MoveNext(); } Assert.AreEqual(new BigInteger(expected[k - 1]), sequence.Current); }