public void Each_fibonacci_number_is_the_sum_of_its_last_2_predecessors() { /* * Select all result sequences with at least 3 elements */ var sequences = Scenario .Messages .ForActionCalls("/fibonacci") .Select(x => x.ResultMessage.Value.Result <FibonacciResult>()?.Sequence) .Where(x => x != null && x.Count() > 2); foreach (var sequence in sequences) { var expectedFibonacciSequence = Fibonacci.CalculateSequence(sequence.Count()); sequence.Should().BeEquivalentTo(expectedFibonacciSequence); } }
public void All_feedback_messages_contain_a_valid_fibonacci_sequence() { /* * Select all feedback sequences */ var sequences = Scenario .Messages .ForActionCalls("/fibonacci") .SelectMany(x => x.FeedbackMessages) .Select(f => f?.Value.Feedback <FibonacciFeedback>()?.Sequence) .Where(x => x != null); foreach (var sequence in sequences) { var expectedFibonacciSequence = Fibonacci.CalculateSequence(sequence.Count()); sequence.Should().BeEquivalentTo(expectedFibonacciSequence); } }
public void All_results_contain_valid_fibonacci_sequences() { /* * This is an alternative to the 3 tests before. * It checks if all result sequences represent a valid fibonacci row. */ //Select all result sequences var sequences = Scenario .Messages .ForActionCalls("/fibonacci") .Select(x => x.ResultMessage.Value.Result <FibonacciResult>()?.Sequence) .Where(x => x != null); foreach (var sequence in sequences) { var expectedFibonacciSequence = Fibonacci.CalculateSequence(sequence.Count()); sequence.Should().BeEquivalentTo(expectedFibonacciSequence); } }
public void Every_feedback_message_adds_a_new_number_to_the_sequence() { var actionFeedbacks = Scenario .Messages .ForActionCalls("/fibonacci") .Select(x => x.FeedbackMessages? .Select(f => f.Value.Feedback <FibonacciFeedback>().Sequence)) .Where(x => x != null && x.Any()); foreach (var actionFeedback in actionFeedbacks) { for (var i = 0; i < actionFeedback.Count(); i++) { var expectedCount = i + 3; var expectedSequence = Fibonacci.CalculateSequence(expectedCount); var feedback = actionFeedback.Skip(i).First(); feedback.Should().HaveCount(expectedCount); feedback.Should().BeEquivalentTo(expectedSequence); } } }