public void Load_XMLFile_Expect_TwoItemInList()
        {
            //Arrange
            XmlExtractor xmlExtractor = new XmlExtractor();
            var          xmlFilePath  = (@"TestData\ValidXML.xml");

            //Act
            var testList = xmlExtractor.LoadXml(xmlFilePath);

            //Assert
            Assert.AreEqual(testList.Count, 2);
        }
        public void Load_InvalidXMLFile_ExpectExceptionThrown()
        {
            //Arrange
            //Invalid path set
            XmlExtractor xmlExtractor = new XmlExtractor();
            var          xmlFilePath  = (@"TestData\InvalidXML.xml");

            //Act
            var testList = xmlExtractor.LoadXml(xmlFilePath);

            //Assert above method - Expected exception is set
        }
        //This test has for only purpose to check if the the list has been populater correctly from the file
        public void Load_XMLFile_Expect_CorrectHorsesNames()
        {
            //Arrange
            XmlExtractor xmlExtractor = new XmlExtractor();
            var          xmlFilePath  = (@"TestData\ValidXML.xml");

            //Act
            var testList = xmlExtractor.LoadXml(xmlFilePath);

            //Assert
            Assert.AreEqual(testList[0].Name, "Advancing");
            Assert.AreEqual(testList[1].Name, "Coronel");
        }
Example #4
0
        static void Main(string[] args)
        {
            //One extractor per file format
            JsonExtractor.JsonExtractor jsonExtractor = new JsonExtractor.JsonExtractor();
            XmlExtractor xmlExtractor = new XmlExtractor();

            HorseHandler.HorseHandler horseHandler = new HorseHandler.HorseHandler();

            //Retrive file from shared folder
            // Future development would involve an API to retrieve file and parse extension
            var xmlFilePath  = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), @"Data\Caulfield_Race1.xml");
            var jsonFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), @"Data\Wolferhampton_Race1.json");

            List <HorseDto> SortedHorsesList = new List <HorseDto>();

            try
            {
                Console.WriteLine("Json file extraction:");
                SortedHorsesList = jsonExtractor.LoadJson(jsonFilePath);
                horseHandler.SortAndDisplayHorseList(SortedHorsesList);

                Console.WriteLine("\n------------------------------");

                Console.WriteLine("XML file extraction:");
                SortedHorsesList = xmlExtractor.LoadXml(xmlFilePath);
                horseHandler.SortAndDisplayHorseList(SortedHorsesList);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }


            Console.WriteLine("\nPress any key to exit");
            Console.ReadKey();
        }