Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
 public SalesRecordAdapterTest()
 {
     salesRecordAdapter = new Factory().SalesRecordAdapter;
 }