Represents a yearly schedule of Cycles.
        public void QualityPeriodCycleTest()
        {
            DateTime asOf = DateTime.Now;
            YearlySchedule yearlySchedule = new YearlySchedule(asOf);
            Cycle parent = yearlySchedule.Cycles.First();
            Quality quality = null;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();

            QualityPeriod target = new QualityPeriod(parent, quality, startDate, endDate);

            Cycle actual, expected;
            actual = target.Cycle;
            expected = parent;

            Assert.AreEqual<Cycle>(expected, actual, "Cycle not storing and returning proper values.");
        }
        public void QualityPeriodAsOfTest()
        {
            DateTime asOf = DateTime.Now;
            YearlySchedule yearlySchedule = new YearlySchedule(asOf);
            Cycle parent = new Cycle(yearlySchedule, DateTime.MinValue);
            Quality quality = null;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();

            QualityPeriod target = new QualityPeriod(parent, quality, startDate, endDate);

            DateTime actual, expected;
            actual = target.AsOf;
            expected = asOf;

            Assert.AreEqual<DateTime>(expected, actual, "AsOf not correctly retrieving from parent object heirarchy.");
        }
Exemple #3
0
 /// <summary>
 /// Constructs a Cycle with the given parent YearlySchedule and
 /// starting date
 /// </summary>
 /// <param name="parent">Parent <see cref="EternalPlay.Technomonk.BusinessLayer.YearlySchedule"/> reference.</param>
 /// <param name="startDate"><see cref="System.DateTime" />Starting date for the cycle.</param>
 internal Cycle(YearlySchedule parent, DateTime startDate)
 {
     _yearlySchedule = parent;
     _qualityPeriods = CreateQualityPeriods(startDate, this);
 }
        /// <summary>
        /// Builds a <see cref="List{Cycle}" /> based on the given as of date.
        /// </summary>
        /// <param name="asOf">As of date for the cycles to build</param>
        /// <param name="parent">Parent YearlySchedule for the created Cycles</param>
        /// <returns><see cref="List{Cycle}" /></returns>
        private static List<Cycle> BuildCycles(DateTime asOf, YearlySchedule parent)
        {
            DateTime cycleStart, cycleEnd, endOfYear;
            List<Cycle> cycles = new List<Cycle>();

            cycleStart = asOf.FirstMondayOfYear();
            cycleEnd = cycleStart.AddDays(CycleDefinition.QualityDefinitions.Count * 7);
            endOfYear = asOf.LastDayOfYear();

            while (cycleEnd <= endOfYear) {
                Cycle newCycle = new Cycle(parent, cycleStart);
                cycles.Add(newCycle);

                cycleStart = cycleStart.AddDays(CycleDefinition.QualityDefinitions.Count * 7);
                cycleEnd = cycleStart.AddDays(CycleDefinition.QualityDefinitions.Count * 7);
            }

            return cycles;
        }
        public void QualityPeriodIsCurrentNotYetCurrentTest()
        {
            DateTime asOf = DateTime.Now.FirstMondayOfYear().AddDays(1); //NOTE: Set as of into first cycle
            YearlySchedule yearlySchedule = new YearlySchedule(asOf);
            Cycle parent = yearlySchedule.Cycles.First();
            Quality quality = null;
            DateTime startDate = parent.QualityPeriods.Last().StartDate;
            DateTime endDate = parent.QualityPeriods.Last().EndDate;

            QualityPeriod target = new QualityPeriod(parent, quality, startDate, endDate);

            bool actual, expected;
            actual = target.IsCurrent;
            expected = false;

            Assert.AreEqual<bool>(expected, actual, "IsActive not correctly deriving from parent object heirarchy when not active.");
        }
        public void QualityPeriodIsActiveActiveNotCurrentTest()
        {
            DateTime asOf = DateTime.Now.FirstMondayOfYear().AddDays(7); //NOTE:  Set as of in active but not current period
            YearlySchedule yearlySchedule = new YearlySchedule(asOf);
            Cycle parent = yearlySchedule.Cycles.First();
            Quality quality = null;
            DateTime startDate = parent.QualityPeriods.First().StartDate;
            DateTime endDate = parent.QualityPeriods.First().EndDate;

            QualityPeriod target = new QualityPeriod(parent, quality, startDate, endDate);

            bool actual, expected;
            actual = target.IsActive;
            expected = true; //NOTE:  this is active/not current test

            Assert.AreEqual<bool>(expected, actual, "IsActive not correctly deriving from parent object heirarchy when active but not current.");
        }