コード例 #1
0
        public void CanGetDisabledStatus()
        {
            Promotion target = new Promotion();

            target.IsEnabled    = false;
            target.StartDateUtc = new DateTime(2010, 09, 1, 0, 0, 0);    // Sept 1st, 2010
            target.EndDateUtc   = new DateTime(2010, 11, 1, 23, 59, 59); // Nov. 1, 2010


            DateTime        currentUtcTime = new DateTime(2010, 9, 15, 23, 59, 59); // Sept. 15th, 11:59:59 pm
            PromotionStatus expected       = PromotionStatus.Disabled;
            PromotionStatus actual;

            actual = target.GetStatus(currentUtcTime);
            Assert.AreEqual(expected, actual, "Sept 15th should return disabled");


            DateTime        currentUtcTime2 = new DateTime(2009, 9, 1, 0, 0, 0); // Sept. 1th, 2009
            PromotionStatus expected2       = PromotionStatus.Disabled;
            PromotionStatus actual2;

            actual2 = target.GetStatus(currentUtcTime2);
            Assert.AreEqual(expected2, actual2, "Sept 1st from one year ago should return disabled status");

            DateTime        currentUtcTime3 = new DateTime(2012, 11, 1, 23, 59, 59); // Sept. 1th, 2012
            PromotionStatus expected3       = PromotionStatus.Disabled;
            PromotionStatus actual3;

            actual3 = target.GetStatus(currentUtcTime3);
            Assert.AreEqual(expected3, actual3, "Nov 1st from 2012 should return disabled status");
        }
コード例 #2
0
        public void CanGetActiveStatus()
        {
            Promotion target = new Promotion();

            target.IsEnabled    = true;
            target.StartDateUtc = new DateTime(2010, 09, 1, 0, 0, 0);    // Sept 1st, 2010
            target.EndDateUtc   = new DateTime(2010, 11, 1, 23, 59, 59); // Nov. 1, 2010


            DateTime        currentUtcTime = new DateTime(2010, 9, 15, 23, 59, 59); // Sept. 15th, 11:59:59 pm
            PromotionStatus expected       = PromotionStatus.Active;
            PromotionStatus actual;

            actual = target.GetStatus(currentUtcTime);
            Assert.AreEqual(expected, actual, "Sept 15th should return active status");


            DateTime        currentUtcTime2 = new DateTime(2010, 9, 1, 0, 0, 0); // Sept. 1th, 2010
            PromotionStatus expected2       = PromotionStatus.Active;
            PromotionStatus actual2;

            actual2 = target.GetStatus(currentUtcTime2);
            Assert.AreEqual(expected2, actual2, "Sept 1st should return active status");

            DateTime        currentUtcTime3 = new DateTime(2010, 11, 1, 23, 59, 59); // Sept. 1th, 2010
            PromotionStatus expected3       = PromotionStatus.Active;
            PromotionStatus actual3;

            actual3 = target.GetStatus(currentUtcTime3);
            Assert.AreEqual(expected3, actual3, "Nov 1st should return active status");
        }
コード例 #3
0
        public void CanGetUpcomingStatus()
        {
            Promotion target = new Promotion();

            target.IsEnabled    = true;
            target.StartDateUtc = new DateTime(2010, 09, 1, 0, 0, 0);    // Sept 1st, 2010
            target.EndDateUtc   = new DateTime(2010, 11, 1, 23, 59, 59); // Nov. 1, 2010


            DateTime        currentUtcTime = new DateTime(2010, 08, 1, 0, 0, 0);
            PromotionStatus expected       = PromotionStatus.Upcoming;
            PromotionStatus actual;

            actual = target.GetStatus(currentUtcTime);
            Assert.AreEqual(expected, actual, "Augst 1st should return upcoming status");


            DateTime        currentUtcTime2 = new DateTime(2010, 8, 31, 23, 59, 59); // August 31st
            PromotionStatus expected2       = PromotionStatus.Upcoming;
            PromotionStatus actual2;

            actual2 = target.GetStatus(currentUtcTime2);
            Assert.AreEqual(expected2, actual2, "August 31th should return Upcoming status");
        }
コード例 #4
0
        public void CanGetExpiredStatus()
        {
            Promotion target = new Promotion();

            target.IsEnabled    = true;
            target.StartDateUtc = new DateTime(2010, 09, 1, 0, 0, 0);    // Sept 1st, 2010
            target.EndDateUtc   = new DateTime(2010, 11, 1, 23, 59, 59); // Nov. 1, 2010


            DateTime        currentUtcTime = new DateTime(2010, 11, 2, 0, 0, 0); // Nov. 2nd
            PromotionStatus expected       = PromotionStatus.Expired;
            PromotionStatus actual;

            actual = target.GetStatus(currentUtcTime);
            Assert.AreEqual(expected, actual, "Nov 2nd should return Expired status");


            DateTime        currentUtcTime2 = new DateTime(2011, 9, 1, 0, 0, 0); // Sept. 1th, 2011
            PromotionStatus expected2       = PromotionStatus.Expired;
            PromotionStatus actual2;

            actual2 = target.GetStatus(currentUtcTime2);
            Assert.AreEqual(expected2, actual2, "Sept 1st should return Expired status");
        }