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(); }
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); }