public void TestGetMaxProfit() { List <SalesRecord> salesRecords = new List <SalesRecord> { new SalesRecord { TotalProfit = 17.2 }, new SalesRecord { TotalProfit = 17.0 }, new SalesRecord { TotalProfit = 0.0 }, new SalesRecord { TotalProfit = 17.1 }, new SalesRecord { TotalProfit = 10.0 } }; decimal actual = salesRecordAnalyzer.GetMaxProfit(salesRecords); Assert.Equal((decimal)17.2, 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); }
private void Run() { Factory factory = new Factory(); ISalesRecordAdapter salesRecordAdapter = factory.SalesRecordAdapter; ISalesRecordAnalyzer salesRecordAnalyzer = factory.SalesRecordAnalyzer; List <SalesRecord> salesRecords = salesRecordAdapter.GetSalesRecordsFromCsvFile(filePath); List <string> countries = salesRecordAnalyzer.GetCountries(salesRecords); countries.Sort(); countries.ForEach(country => Console.WriteLine(country)); int countryCount = salesRecordAnalyzer.GetCountryCount(salesRecords); Console.WriteLine(countryCount); decimal maxProfit = salesRecordAnalyzer.GetMaxProfit(salesRecords); Console.WriteLine(maxProfit); Console.ReadLine(); }