Пример #1
0
        public void TestGetCountries()
        {
            List <SalesRecord> salesRecords = new List <SalesRecord>
            {
                new SalesRecord {
                    Country = "Country1"
                },
                new SalesRecord {
                    Country = "Country2"
                },
                new SalesRecord {
                    Country = "Country3"
                },
                new SalesRecord {
                    Country = "country3"
                },
                new SalesRecord {
                    Country = "Country2"
                }
            };

            List <string> actual = salesRecordAnalyzer.GetCountries(salesRecords);

            Assert.Equal(4, actual.Count);
            Assert.Contains(actual, country => country == "Country1");
            Assert.Contains(actual, country => country == "Country2");
            Assert.Contains(actual, country => country == "Country3");
            Assert.Contains(actual, country => country == "country3");
        }
Пример #2
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);
        }
Пример #3
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();
        }