public void ShouldReturnHorsesForRequestedFeed()
        {
            // Arrange
            var FeedId = Guid.NewGuid().ToString();
            var feed   = new Feed {
                FeedId = FeedId, Races = new[] { new Race {
                                                     RaceNumber = 1, Horses = new[] { new Horse() }
                                                 } }
            };

            A.CallTo(() => _repository.Read()).Returns(new[] { feed });
            var request = new GetHorsesWithPriceRequest {
                FeedId = FeedId
            };

            // Act
            var actual = _subject.Query(request);

            // Assert
            Assert.That(actual, Is.Not.Null);
            Assert.That(actual.Horses.Count(), Is.EqualTo(1));
        }
Example #2
0
        static void Main(string[] args)
        {
            //TODO: Abstract to a Facade to allow for testability.
            while (true)
            {
                DisplayInstructions();

                //TODO: Abstract away user input handling
                var userResponse = Console.ReadLine().ToLowerInvariant();

                if (userResponse == "q")
                {
                    break;
                }

                string file = string.Empty;

                if (userResponse == "1")
                {
                    file = "FeedData/Caulfield_Race1.xml";
                }
                else if (userResponse == "2")
                {
                    file = "FeedData/Wolferhampton_Race1.json";
                }
                else
                {
                    Console.WriteLine("Invalid option. Please try again");
                    continue;
                }

                string feedId = null;

                try
                {
                    // 1. Ingest feed.

                    /* This would otherwise be done out of process
                     * but for purposes of this exercise, I ingest
                     * the feed first within this application. */
                    feedId = _ingester.Ingest(file);
                }
                catch (FeedTypeNotSupportedException e)
                {
                    Console.WriteLine($"An exception occured while trying to process the input feed {userResponse}. Error details: {e.Message}.");
                }

                Console.WriteLine($"Feed ingested successfully with id: {feedId}");

                // 2. Transform the feed data into a view model
                //TODO: Use builder pattern here
                var request = new GetHorsesWithPriceRequest
                {
                    FeedId = feedId
                };
                var response = _query.Query(request);

                // 3. Display the results
                _renderer.Render(response);
            }
        }