public void TestCalculateCost_EarlyAbsolute()
        {
            var earlyCuttofDate = new DateTime(2000, 1, 1);
            var defaultCost = 10M;
            var earlyCost = 5M;
            var ev = new Event();
            ev.Cost = defaultCost;
            var occurrence = new EventOccurrence() { Event = ev, Cost = defaultCost };
            occurrence.AddOccurrenceDate(new DateTime(2000, 3, 1), new DateTime(2000, 3, 2));
            var earlySchedule = new PricingSchedule(earlyCost, earlyCuttofDate);
            occurrence.SetEarlyRegistrationPrice(earlySchedule);

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(earlyCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(-1)));
            Assert.AreEqual(earlyCost, occurrence.CalculateCost(earlyCuttofDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(1)));

            occurrence.DisablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(-1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCuttofDate.AddDays(1)));
        }
 public void TestEffectiveCost()
 {
     var ev = new Event();
     var occurrence = new EventOccurrence() { Event = ev };
     occurrence.Cost = 1500m;
     Assert.AreEqual(occurrence.CalculateCost(DateTime.Now), occurrence.EffectiveCost);
 }
        public void TestCalculateCost_LateRelative()
        {
            var firstOccurrenceDate = new DateTime(2000, 1, 1);
            var lateDays = 5;
            var defaultCost = 10M;
            var lateCost = 15M;
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            occurrence.AddOccurrenceDate(firstOccurrenceDate, firstOccurrenceDate.AddHours(1));
            occurrence.Cost = defaultCost;
            var lateSchedule = new PricingSchedule(lateCost, lateDays);
            occurrence.SetLateRegistrationPrice(lateSchedule);
            occurrence.SetRegistrationDates(null, firstOccurrenceDate.AddDays(-1));

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-6)));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-5)));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-4)));

            occurrence.DisablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-6)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-5)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(firstOccurrenceDate.AddDays(-4)));
        }
        public void TestCalculateCost_NoSchedule()
        {
            var now = new DateTime(2000, 1, 1);
            var ev = new Event();

            var occurrence = new EventOccurrence() { Event = ev };
            Assert.AreEqual(0m, occurrence.CalculateCost(now));

            occurrence.Cost = 100.00m;
            Assert.AreEqual(100.00m, occurrence.CalculateCost(now));
            occurrence.Cost = 1500m;
            Assert.AreEqual(1500m, occurrence.CalculateCost(now));
        }
        public void TestCalculateCost_LateAbsolute()
        {
            var lateDate = new DateTime(2000, 1, 1);
            var defaultCost = 10M;
            var lateCost = 15M;
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            occurrence.AddOccurrenceDate(lateDate.AddDays(30), lateDate.AddDays(31));
            occurrence.Cost = defaultCost;
            var lateSchedule = new PricingSchedule(lateCost, lateDate);
            occurrence.SetLateRegistrationPrice(lateSchedule);

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(-1)));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(lateDate));
            Assert.AreEqual(lateCost, occurrence.CalculateCost(lateDate.AddDays(1)));

            occurrence.DisablePricingSchedule();

            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(-1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(1)));
        }