static void Main(string[] args) { var caulfieldParser = new CaulfieldParser(new XmlReader(xmlPath)); var wolferhamptonParser = new WolferHamptonParser(new JSonReader(jsonPath)); var combinedList = caulfieldParser.GetHorses(); var wolferHorses = wolferhamptonParser.GetHorses(); combinedList.AddRange(wolferHorses); if (combinedList != null && combinedList.Any()) { combinedList.OrderBy(horse => horse.Price).ToList().ForEach(item => { Console.WriteLine($"horse name: {item.Name} price: {item.Price}"); }); Console.ReadLine(); } }
public void Test_WolferHapmtonParser() { var jsonReader = new JSonReader(jsonPath); var wolferHamptonParser = new WolferHamptonParser(jsonReader); var wolferHamptonHorses = wolferHamptonParser.GetHorses(); Assert.Equal("Toolatetodelegate", wolferHamptonHorses[0].Name); Assert.Equal(10.0m, wolferHamptonHorses[0].Price); var jsonReaderWithBadPath = new JSonReader(wrongPath); var exception1 = Record.Exception(() => new WolferHamptonParser(jsonReaderWithBadPath)); Assert.IsType<IOException>(exception1); Assert.Equal("File path is wrong or File not found", exception1.Message); //var xmlReader1 = new Mock<IXmlReader>(); //xmlReader1.Setup(rpr => rpr.FetchData()).Returns(caulfieldModelWithEmptyData); //var exception2 = Record.Exception(() => new CaulfieldParser(xmlReader1.Object)); //Assert.IsType<NullReferenceException>(exception2); }