public void TestOrderByShipDate() { List <DateTime> expected = new List <DateTime> { DateTime.Parse("4/20/2013"), DateTime.Parse("4/18/2014"), DateTime.Parse("4/19/2014"), DateTime.Parse("4/20/2014"), DateTime.Parse("3/10/2019") }; List <SalesRecord> salesRecords = new List <SalesRecord> { new SalesRecord { ShipDate = DateTime.Parse("4/19/2014") }, new SalesRecord { ShipDate = DateTime.Parse("4/18/2014") }, new SalesRecord { ShipDate = DateTime.Parse("4/20/2014") }, new SalesRecord { ShipDate = DateTime.Parse("4/20/2013") }, new SalesRecord { ShipDate = DateTime.Parse("3/10/2019") } }; List <DateTime> actual = salesRecordAnalyzer.OrderByShipDate(salesRecords) .Select(record => record.ShipDate).ToList(); Assert.True(expected.SequenceEqual(actual)); }
private void Run() { Factory factory = new Factory(); ISalesRecordAdapter salesRecordAdapter = factory.SalesRecordAdapter; List <SalesRecord> salesRecords = salesRecordAdapter.GetSalesRecordsFromCsvFile(filePath); ISalesRecordAnalyzer salesRecordAnalyzer = factory.SalesRecordAnalyzer; List <string> countries = salesRecordAnalyzer.GetCountries(salesRecords); //Testing for Country List countries.Sort(); countries.ForEach(country => Console.WriteLine(country)); Console.ReadLine(); //Testing for Country Count int countryCount = salesRecordAnalyzer.GetCountryCount(salesRecords); Console.WriteLine(countryCount); Console.ReadLine(); //Testing for MaxProfit decimal maxProfit = salesRecordAnalyzer.GetMaxProfit(salesRecords); Console.WriteLine($"Maximum Profit is: {maxProfit}"); Console.ReadLine(); //Testing for TotalRevenue decimal totalRevenue = salesRecordAnalyzer.GetTotalRevenue(salesRecords); Console.WriteLine($"Total Revenue is: {totalRevenue}"); Console.ReadLine(); //Testing for OrderByShipDate List <SalesRecord> ascendingOrderOfShipDates = salesRecordAnalyzer.OrderByShipDate(salesRecords); ascendingOrderOfShipDates.ForEach(record => Console.WriteLine(record.OrderDate.ToString("M/d/yyyy"))); Console.ReadLine(); //Testing for OrderByUnitsSoldDescending List <SalesRecord> orderByUnitsSoldDescending = salesRecordAnalyzer.OrderByUnitsSoldDescending(salesRecords); orderByUnitsSoldDescending.ForEach(record => Console.WriteLine(record.UnitsSold)); Console.ReadLine(); //Testing for AreOrderDatesBefore DateTime cutoffDate = DateTime.Parse("7/26/2017"); Console.WriteLine(salesRecordAnalyzer.AreOrderDatesBefore(cutoffDate, salesRecords)); Console.ReadLine(); //List<SalesRecord> salesRecords = GetSalesRecordsFromFileData(); //int countNorthAmerica = GetCountForNorthAmerica(salesRecords); //Console.WriteLine(countNorthAmerica); }