Ejemplo n.º 1
0
        public void TestAtTimingPoint()
        {
            MockMiscProvider.MockNow = (new DateTime(2004, 3, 5, 7, 12, 5, 0));
            ITiming t = new DayTiming(new TimeOfDayStructure(7, 12, 3));

            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 10));
            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 50));
            Assert.AreEqual(false, t.TimesUp());
        }
Ejemplo n.º 2
0
        public void TestIt()
        {
            var t1 = new MockTask();
            var t2 = new MockTask();
            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 0, 0, 0));
            ITiming ti1 = new DayTiming(new TimeOfDayStructure(1,2,3));
            ITiming ti2 = new DayTiming(new TimeOfDayStructure(1,3,5));
            var ttc = new TimingTaskCollection(new TimingTask(t1, ti1), new TimingTask(t2, ti2));

            var mt = new MockTimer();
            var controller = new TimingTaskController(ttc, mt);
            controller.Start();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 2));
            mt.RaiseElapsed();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 2, 900));
            mt.RaiseElapsed();
            Assert.AreEqual(0, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 3));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 4));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 2, 6));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t1.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 4));
            mt.RaiseElapsed();

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 5));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 6));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            MockMiscProvider.MockNow = (new DateTime(2005, 1, 21, 1, 3, 7));
            mt.RaiseElapsed();
            Assert.AreEqual(1, t2.Times);

            Assert.AreEqual(1, t1.Times);
        }
Ejemplo n.º 3
0
        public void TestIt2()
        {
            MockMiscProvider.MockNow = (new DateTime(2004, 3, 5, 10, 5, 10, 0));
            ITiming t = new DayTiming(new TimeOfDayStructure(7, 12, 3));

            MockMiscProvider.MockNow = (new DateTime(2004, 3, 6, 7, 12, 2));
            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            Assert.AreEqual(true, t.TimesUp());

            t.Reset();
            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            Assert.AreEqual(false, t.TimesUp());

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            Assert.AreEqual(false, t.TimesUp());
        }