Example #1
0
 static void Main(string[] args)
 {
     TimingTask tt1 = new TimingTask( new SecendTask(), new TimeSpanTiming(new TimeSpan(0,0,1)) );
     TimingTask tt5 = new TimingTask( new FiveSecendTask(), new TimeSpanTiming(new TimeSpan(0,0,5)) );
     DateTime dt = DateTime.Now.AddSeconds(8);
     TimingTask ttd = new TimingTask( new DayTask(), new DayTiming(new TimeOfDayStructure(dt.Hour, dt.Minute, dt.Second)) );
     TimingTaskCollection ttc = new TimingTaskCollection( tt1, tt5, ttd );
     TimingTaskController Controller = new TimingTaskController( ttc );
     Controller.Start();
     Console.WriteLine("Press [Enter] to exit.");
     Console.ReadLine();
     Controller.Dispose();
 }
Example #2
0
        public void TestIt()
        {
            var task = new MockTask();
            MockMiscProvider.MockNow = (new DateTime(2004, 3, 5, 10, 5, 10, 0));
            ITiming timing = new TimeSpanTiming(new TimeSpan(0, 5, 0));

            var tt = new TimingTask(task, timing);
            tt.RunIfTimingUp();
            Assert.AreEqual(true, task.DoTaskOk);
            task.DoTaskOk = false;

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            tt.RunIfTimingUp();
            Assert.AreEqual(false, task.DoTaskOk);

            MockMiscProvider.Add(new TimeSpan(0, 1, 1));
            tt.RunIfTimingUp();
            Assert.AreEqual(false, task.DoTaskOk);

            MockMiscProvider.Add(new TimeSpan(0, 3, 1));
            tt.RunIfTimingUp();
            Assert.AreEqual(false, task.DoTaskOk);

            MockMiscProvider.Add(new TimeSpan(0, 0, 56));
            tt.RunIfTimingUp();
            Assert.AreEqual(false, task.DoTaskOk);

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            tt.RunIfTimingUp();
            Assert.AreEqual(true, task.DoTaskOk);
            task.DoTaskOk = false;

            MockMiscProvider.Add(new TimeSpan(0, 0, 1));
            tt.RunIfTimingUp();
            Assert.AreEqual(false, task.DoTaskOk);

            MockMiscProvider.Add(new TimeSpan(0, 5, 8));
            tt.RunIfTimingUp();
            Assert.AreEqual(true, task.DoTaskOk);
        }