Represents a single cycle of quality periods
 /// <summary>
 /// Constructs a QualityPeriod with the given quality and period definition data
 /// </summary>
 /// <param name="parent">Parent <see cref="EternalPlay.Technomonk.BusinessLayer.Cycle" /> object.</param>
 /// <param name="quality">Quality being defined for the period</param>
 /// <param name="startDate">Starting <see cref="System.DateTime" /> for the period.</param>
 /// <param name="endDate">Ending <see cref="System.DateTime" /> for the period.</param>
 internal QualityPeriod(Cycle parent, Quality quality, DateTime startDate, DateTime endDate)
 {
     _cycle = parent;
     _quality = quality;
     _startDate = startDate;
     _endDate = endDate;
 }
        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
        private static ICollection<QualityPeriod> CreateQualityPeriods(DateTime cycleStart, Cycle parent)
        {
            List<QualityPeriod> qualityPeriods = new List<QualityPeriod>();
            DateTime periodStart, periodEnd;

            periodStart = cycleStart;
            periodEnd = cycleStart.AddDays(7).AddMilliseconds(-1);

            foreach (Quality q in CycleDefinition.QualityDefinitions.OrderBy(x => x.SortOrder)) {
                QualityPeriod qp = new QualityPeriod(parent, q, periodStart, periodEnd);
                qualityPeriods.Add(qp);

                periodStart = periodStart.AddDays(7);
                periodEnd = periodStart.AddDays(7).AddMilliseconds(-1);
            }

            return qualityPeriods;
        }
        /// <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;
        }