Example #1
0
        public List <Horse> GetAllHorses()
        {
            _logger.Debug("Entered HorseService:GetAllHorses");

            var meeting = _caulfieldRepository.GetMeeting();
            var fixture = _wolferhamptonRepository.GetFixture();

            // With time i would have refactored these 2 methods into separate transform classes and injected them in
            var horses = TransformCaulfieldMeetingToHorses(meeting);
            var wolferhamptonHorses = TransformWolferhamptonFixtureToHorses(fixture);

            horses.AddRange(wolferhamptonHorses);

            _logger.Debug("Exited HorseService:GetAllHorses");
            return(horses.OrderBy(a => a.Price).ToList());
        }
Example #2
0
        public void GetAllHorses_ReturnsHorsesSortedByPriceAsc()
        {
            _mockCaulfieldRepository.GetMeeting().Returns(GetMockMeeting());
            _mockWolferhamptonRepository.GetFixture().Returns(GetMockFixture());

            var horseService = new HorseService(
                _mockCaulfieldRepository,
                _mockWolferhamptonRepository,
                Substitute.For <ILogger>()
                );

            var horses = horseService.GetAllHorses();

            Assert.True(horses[0].Name == "Caulfield Horse 2");
            Assert.True(horses[1].Name == "Wolferhampton Horse 2");
            Assert.True(horses[2].Name == "Wolferhampton Horse 1");
            Assert.True(horses[3].Name == "Caulfield Horse 1");
            Assert.True(horses[4].Name == "Wolferhampton Horse 3");
        }