public void TestCalculateBucketNoOrder()
        {
            int      id                       = 1;
            DateTime?orderDate                = null;
            DateTime cohortDate               = DateTime.Now;
            string   cohortIdentifier         = "1/1-1/7";
            int      cohortPeriod             = 0;
            ICustomerOrderDataPoint dataPoint = new CustomerOrderDataPoint(id, orderDate, cohortDate, cohortIdentifier, cohortPeriod);

            dataPoint = OrderBucketCalculator.CalculateBucket(dataPoint);
            Assert.AreEqual(0, dataPoint.CohortPeriod);
        }
        public void TestCalculateBucketOrder14DaysAfterSignupInBucket3()
        {
            int      id                       = 1;
            DateTime?orderDate                = DateTime.Now.AddDays(14);
            DateTime cohortDate               = DateTime.Now;
            string   cohortIdentifier         = "1/1-1/7";
            int      cohortPeriod             = 0;
            ICustomerOrderDataPoint dataPoint = new CustomerOrderDataPoint(id, orderDate, cohortDate, cohortIdentifier, cohortPeriod);

            dataPoint = OrderBucketCalculator.CalculateBucket(dataPoint);
            Assert.AreEqual(3, dataPoint.CohortPeriod);
        }
Beispiel #3
0
        private static void GenerateReport(string customerFile, string orderFile)
        {
            ICollection <ICustomer> customers = LoadCustomerData(customerFile, orderFile);
            var data = IdentifyCohorts(customers);

            data = data.Select(d => OrderBucketCalculator.CalculateBucket(d)).ToList();

            //using (var writer = new StreamWriter("data.csv"))
            //{
            //    foreach (var item in data)
            //    {
            //        writer.WriteLine(item.ToString());
            //    }
            //}

            var reportGenerator = new HtmlReportGenerator("report.html");

            reportGenerator.WriteReport(data);
        }