Represents a Quality expressed through a duration of time.
        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.");
        }
示例#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;
        }
        public void QualityPeriodEndDateTest()
        {
            Cycle parent = null;
            Quality quality = null;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();

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

            DateTime actual, expected;
            actual = target.EndDate;
            expected = endDate;

            Assert.AreEqual<DateTime>(expected, actual, "EndDate not storing and returning proper values.");
        }
        public void QualityPeriodQualityPeriodConstructorTest()
        {
            Cycle parent = null;
            Quality quality = null;
            DateTime startDate = new DateTime();
            DateTime endDate = new DateTime();
            QualityPeriod target = new QualityPeriod(parent, quality, startDate, endDate);

            Assert.IsNotNull(target);
        }
        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.");
        }