public static void CaptureCostScheduleData(EventOccurrenceV2 source, EventOccurrence target)
        {
            Decimal? sourceEarlyCost = GetDecimalValue(source.EarlyCost);
            var sourceEarlyCostEndDate = GetDateTime(source.EarlyCostEndDate);
            var sourceEarlyCostEndDays = GetNullableInt(source.EarlyCostEndDays);

            var earlyScheduleHasNecessaryValues = sourceEarlyCost.HasValue && (sourceEarlyCostEndDate.HasValue || sourceEarlyCostEndDays.HasValue);

            if (earlyScheduleHasNecessaryValues)
            {
                var hasEarlyDateValue = sourceEarlyCostEndDate.HasValue;
                if (hasEarlyDateValue)
                {
                    var EarlyCostPriceSchedule = new PricingSchedule(sourceEarlyCost.Value, sourceEarlyCostEndDate.Value);
                    target.SetEarlyRegistrationPrice(EarlyCostPriceSchedule);
                }
                else
                {
                    var EarlyCostPriceSchedule = new PricingSchedule(sourceEarlyCost.Value, sourceEarlyCostEndDays.Value);
                    target.SetEarlyRegistrationPrice(EarlyCostPriceSchedule);
                }
            }
            else
            {
                target.SetEarlyRegistrationPrice(null);
            }

            Decimal? sourceLateCost = GetDecimalValue(source.LateCost);
            var sourceLateCostStartDate = GetDateTime(source.LateCostStartDate);
            var sourceLateCostStartDays = GetNullableInt(source.LateCostStartDays);

            var lateScheduleHasNecessaryValues = sourceLateCost.HasValue && (sourceLateCostStartDate.HasValue || sourceLateCostStartDays.HasValue);
            if (lateScheduleHasNecessaryValues)
            {
                var hasLateDateValue = sourceLateCostStartDate.HasValue;
                if (hasLateDateValue)
                {
                    var LateCostPriceSchedule = new PricingSchedule(sourceLateCost.Value, sourceLateCostStartDate.Value);
                    target.SetLateRegistrationPrice(LateCostPriceSchedule);
                }
                else
                {
                    var LateCostPriceSchedule = new PricingSchedule(sourceLateCost.Value, sourceLateCostStartDays.Value);
                    target.SetLateRegistrationPrice(LateCostPriceSchedule);
                }
            }
            else
            {
                target.SetLateRegistrationPrice(null);
            }
        }
Пример #2
0
        public void TestIsEarlyAndLateAbsoluteMode_lateAbsolute()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };

            var lateSchedule = new PricingSchedule(10M, new DateTime(1999, 01, 01));
            occurrence.SetLateRegistrationPrice(lateSchedule);

            Assert.IsTrue(occurrence.IsEarlyAndLateAbsoluteMode);
        }
Пример #3
0
        public void TestEnablePricingSchedule_LateSpecified()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            var pricingSchedule = new PricingSchedule(10M, 30);
            occurrence.SetLateRegistrationPrice(pricingSchedule);
            occurrence.EnablePricingSchedule();

            Assert.IsTrue(occurrence.IsPriceScheduleEnabled);
        }
Пример #4
0
        public void TestIsEarlyAndLateAbsoluteMode_earlyAbsoluteLateRelative()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };

            var earlySchedule = new PricingSchedule(10M, new DateTime(1999, 01, 01));
            occurrence.SetEarlyRegistrationPrice(earlySchedule);

            var lateSchedule = new PricingSchedule(10M, 10);
            occurrence.SetLateRegistrationPrice(lateSchedule);

            // this case shouldn't be allowed in the wild...
            // still though, this test should pass
            Assert.IsFalse(occurrence.IsEarlyAndLateAbsoluteMode);
        }
Пример #5
0
        public void TestEnablePricingSchedule()
        {
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            var earlySchedule = new PricingSchedule(10M, 30);
            occurrence.SetEarlyRegistrationPrice(earlySchedule);
            var lateSchedule = new PricingSchedule(20M, 30);
            occurrence.SetLateRegistrationPrice(lateSchedule);
            occurrence.EnablePricingSchedule();

            Assert.IsTrue(occurrence.IsPriceScheduleEnabled);
        }
Пример #6
0
        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)));
        }
Пример #7
0
        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)));
        }
Пример #8
0
        public void TestCalculateCost_EarlyAndLate_Absolute()
        {
            var defaultCost = 10M;
            var ev = new Event();
            var occurrence = new EventOccurrence() { Event = ev };
            occurrence.AddOccurrenceDate(new DateTime(2000, 3, 1), new DateTime(2000, 3, 2));
            occurrence.Cost = defaultCost;

            var earlyCutoffDate = new DateTime(2000, 1, 1);
            var earlyCost = 5M;
            var earlySchedule = new PricingSchedule(earlyCost, earlyCutoffDate);
            occurrence.SetEarlyRegistrationPrice(earlySchedule);

            var lateDate = new DateTime(2000, 2, 1);
            var lateCost = 15M;
            var lateSchedule = new PricingSchedule(lateCost, lateDate);
            occurrence.SetLateRegistrationPrice(lateSchedule);

            occurrence.EnablePricingSchedule();

            Assert.AreEqual(earlyCost, occurrence.CalculateCost(earlyCutoffDate.AddDays(-1)));
            Assert.AreEqual(earlyCost, occurrence.CalculateCost(earlyCutoffDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCutoffDate.AddDays(1)));
            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(earlyCutoffDate.AddDays(-1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCutoffDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(earlyCutoffDate.AddDays(1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(-1)));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate));
            Assert.AreEqual(defaultCost, occurrence.CalculateCost(lateDate.AddDays(1)));
        }
        private static void CaptureCostScheduleData(EventOccurrence source, EventOccurrence target)
        {
            var earlyScheduleHasNecessaryValues = source.EarlyCost.HasValue && (source.EarlyCostEndDate.HasValue || source.EarlyCostEndDays.HasValue);

            if (earlyScheduleHasNecessaryValues)
            {
                var hasEarlyDateValue = source.EarlyCostEndDate.HasValue;
                if (hasEarlyDateValue)
                {
                    var EarlyCostPriceSchedule = new PricingSchedule(source.EarlyCost.Value, source.EarlyCostEndDate.Value);
                    target.SetEarlyRegistrationPrice(EarlyCostPriceSchedule);
                }
                else
                {
                    var EarlyCostPriceSchedule = new PricingSchedule(source.EarlyCost.Value, source.EarlyCostEndDays.Value);
                    target.SetEarlyRegistrationPrice(EarlyCostPriceSchedule);
                }
            }
            else
            {
                target.SetEarlyRegistrationPrice(null);
            }

            var lateScheduleHasNecessaryValues = source.LateCost.HasValue && (source.LateCostStartDate.HasValue || source.LateCostStartDays.HasValue);
            if (lateScheduleHasNecessaryValues)
            {
                var hasLateDateValue = source.LateCostStartDate.HasValue;
                if (hasLateDateValue)
                {
                    var LateCostPriceSchedule = new PricingSchedule(source.LateCost.Value, source.LateCostStartDate.Value);
                    target.SetLateRegistrationPrice(LateCostPriceSchedule);
                }
                else
                {
                    var LateCostPriceSchedule = new PricingSchedule(source.LateCost.Value, source.LateCostStartDays.Value);
                    target.SetLateRegistrationPrice(LateCostPriceSchedule);
                }
            }
            else
            {
                target.SetLateRegistrationPrice(null);
            }
        }