Exemple #1
0
        public SequenceNumbers CalculateSequence(int number)
        {
            var sequenceNumbers = new SequenceNumbers
            {
                AllNumbersUptoGivenNumber              = _sequenceGenerator.GenerateSequenceFor(number, SequenceType.AllNumbers),
                EvenNumbersUptoGivenNumber             = _sequenceGenerator.GenerateSequenceFor(number, SequenceType.EvenNumbers),
                OddNumbersUptoGivenNumber              = _sequenceGenerator.GenerateSequenceFor(number, SequenceType.OddNumbers),
                FizzBuzzSequenceNumbersUptoGivenNumber = _sequenceGenerator.GenerateSequenceFor(number, SequenceType.FizzBuzzNumbers)
            };

            return(sequenceNumbers);
        }
        public void SequenceCalculatorServiceReturns_SequenceOf_Odd_Even_AllNumbers_And_FizzBuzzSequence()
        {
            var expectedSequenceNumbers = new SequenceNumbers()
            {
                AllNumbersUptoGivenNumber = new List <string> {
                    "1", "2", "3", "4", "5"
                },
                EvenNumbersUptoGivenNumber = new List <string> {
                    "2", "4"
                },
                OddNumbersUptoGivenNumber = new List <string> {
                    "1", "3", "5"
                },
                FizzBuzzSequenceNumbersUptoGivenNumber = new List <string> {
                    "1", "2", "C", "4", "E"
                }
            };

            _sequenceGenerator.GenerateSequenceFor(5, SequenceType.EvenNumbers).
            Returns(new List <string> {
                "2", "4"
            });
            _sequenceGenerator.GenerateSequenceFor(5, SequenceType.OddNumbers).
            Returns(new List <string> {
                "1", "3", "5"
            });
            _sequenceGenerator.GenerateSequenceFor(5, SequenceType.FizzBuzzNumbers).
            Returns(new List <string> {
                "1", "2", "C", "4", "E"
            });
            _sequenceGenerator.GenerateSequenceFor(5, SequenceType.AllNumbers).
            Returns(new List <string> {
                "1", "2", "3", "4", "5"
            });

            var result = _sequenceCalculatorService.CalculateSequence(5);

            result.Should().BeEquivalentTo(expectedSequenceNumbers);
        }