static void Main(string[] args)
        {
            string path          = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string feedDirectory = $"{Path.GetDirectoryName(path)}\\FeedData";

            var           processFeeds = new ProcessFeedFiles();
            List <string> messages     = new List <string>();

            try
            {
                foreach (string filename in Directory.EnumerateFiles(feedDirectory))
                {
                    messages = processFeeds.ProcessFeedFile(filename);
                    messages.ForEach(message =>
                    {
                        Console.WriteLine(message);
                    });
                    Console.WriteLine(String.Empty);
                }

                // TODO: move file to "processed" location.
                Console.Write("press enter to continue");
                Console.Read();

                Console.Read();
            }
            catch (Exception ex)
            {
                // TODO: log error and move file to "unprocessed" location.
                Console.WriteLine($"processing failed: error message: {ex.Message}.");
                Console.Write("please refer to the app log for further information.");
                Console.Read();
            }
        }
        public void ProcessXMLFeed_ExpectRaceName_ThenSortedNameAndPrice()
        {
            // arrange
            string path     = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string feedFile = $"{Path.GetDirectoryName(path)}\\FeedData\\Caulfield_Race1.xml";

            ProcessFeedFiles service = new ProcessFeedFiles();

            // act
            List <String> messages = service.ProcessXMLFeed(feedFile);

            // assert
            Assert.Equal(3, messages.Count);
            Assert.Equal("Evergreen Turf Plate", messages[0]);
            Assert.Equal("Name: Advancing. Price: 4.2.", messages[1]);
            Assert.Equal("Name: Coronel. Price: 12.", messages[2]);
        }
        public void ProcessJsonFeed_ExpectRaceName_ThenSortedNameAndPrice()
        {
            // arrange
            string path     = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string feedFile = $"{Path.GetDirectoryName(path)}\\FeedData\\Wolferhampton_Race1.json";

            ProcessFeedFiles service = new ProcessFeedFiles();

            // act
            List <String> messages = service.ProcessJSONFeed(feedFile);

            // assert
            Assert.Equal(3, messages.Count);
            Assert.Equal("13:45 @ Wolverhampton", messages[0]);
            Assert.Equal("Name: Fikhaar. Price: 4.4.", messages[1]);
            Assert.Equal("Name: Toolatetodelegate. Price: 10.", messages[2]);
        }
        public void ProcessXMLFeed_FileDoesNotExist_ExpectFileNotFoundException()
        {
            // arrange
            string path     = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string feedFile = $"{Path.GetDirectoryName(path)}\\FeedData\\This_File_Does_Not_Exist.xml";

            ProcessFeedFiles service = new ProcessFeedFiles();

            try
            {
                // Act
                service.ProcessXMLFeed(feedFile);
            }
            catch (Exception ex)
            {
                // Assert
                Assert.IsType <FileNotFoundException>(ex);
            }
        }
        public void ProcessXMLFeed_FileHasNonSupportedExtension_ExpectCorrectMessage()
        {
            // arrange
            string path     = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string feedFile = $"{Path.GetDirectoryName(path)}\\FeedData\\FileWithNonSupportedExtension.xyz";

            ProcessFeedFiles service  = new ProcessFeedFiles();
            List <String>    messages = new List <string>();

            try
            {
                // act
                service.ProcessFeedFile(feedFile);
            }
            catch (Exception ex)
            {
                // assert
                Assert.Contains("cannot process invalid file", ex.Message);
            }
        }