Пример #1
0
        public void TestGetTotalRevenue()
        {
            List <SalesRecord> salesRecords = new List <SalesRecord>
            {
                new SalesRecord {
                    TotalRevenue = 17.2
                },
                new SalesRecord {
                    TotalRevenue = 17.0
                },
                new SalesRecord {
                    TotalRevenue = 0.0
                },
                new SalesRecord {
                    TotalRevenue = 17.1
                },
                new SalesRecord {
                    TotalRevenue = 10.0
                }
            };

            decimal actual = salesRecordAnalyzer.GetTotalRevenue(salesRecords);

            Assert.Equal((decimal)61.3, actual);
        }
Пример #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);
        }