Пример #1
0
 public void TestThrowOnNotifyAtWithUnspecifiedDateTimeKind()
 {
     using (TestSubscriber subscriber = new TestSubscriber()) {
         using (Scheduler scheduler = new Scheduler()) {
             Assert.Throws <ArgumentException>(
                 delegate() {
                 scheduler.NotifyAt(new DateTime(2000, 1, 1), subscriber.Callback);
             }
                 );
         }
     }
 }
Пример #2
0
        public void TestNotifyAt()
        {
            MockTimeSource mockTimeSource = new MockTimeSource(new DateTime(2010, 1, 1));

            using (TestSubscriber subscriber = new TestSubscriber()) {
                using (Scheduler scheduler = new Scheduler(mockTimeSource)) {
                    scheduler.NotifyAt(makeUtc(new DateTime(2010, 1, 2)), subscriber.Callback);

                    mockTimeSource.AdvanceTime(TimeSpan.FromDays(1));

                    Assert.IsTrue(subscriber.WaitForCallback(1000));
                }
            }
        }
Пример #3
0
        public void TestNotifyAtWithDateTimeAdjustment()
        {
            MockTimeSource mockTimeSource = new MockTimeSource(new DateTime(2010, 1, 1));

            using (TestSubscriber subscriber = new TestSubscriber()) {
                using (Scheduler scheduler = new Scheduler(mockTimeSource)) {
                    scheduler.NotifyAt(makeUtc(new DateTime(2010, 1, 2)), subscriber.Callback);

                    // Let 12 hours pass, after that, we simulate a time synchronization
                    // that puts the system 12 hours ahead of the original time.
                    mockTimeSource.AdvanceTime(TimeSpan.FromHours(12));
                    mockTimeSource.AdjustTime(new DateTime(2010, 1, 2));

                    Assert.IsTrue(subscriber.WaitForCallback(1000));
                }
            }
        }
Пример #4
0
    public void TestNotifyAtWithDateTimeAdjustment() {
      MockTimeSource mockTimeSource = new MockTimeSource(new DateTime(2010, 1, 1));
      using(TestSubscriber subscriber = new TestSubscriber()) {
        using(Scheduler scheduler = new Scheduler(mockTimeSource)) {
          scheduler.NotifyAt(makeUtc(new DateTime(2010, 1, 2)), subscriber.Callback);

          // Let 12 hours pass, after that, we simulate a time synchronization
          // that puts the system 12 hours ahead of the original time.
          mockTimeSource.AdvanceTime(TimeSpan.FromHours(12));
          mockTimeSource.AdjustTime(new DateTime(2010, 1, 2));

          Assert.IsTrue(subscriber.WaitForCallback(1000));
        }
      }
    }
Пример #5
0
    public void TestNotifyAt() {
      MockTimeSource mockTimeSource = new MockTimeSource(new DateTime(2010, 1, 1));
      using(TestSubscriber subscriber = new TestSubscriber()) {
        using(Scheduler scheduler = new Scheduler(mockTimeSource)) {
          scheduler.NotifyAt(makeUtc(new DateTime(2010, 1, 2)), subscriber.Callback);

          mockTimeSource.AdvanceTime(TimeSpan.FromDays(1));

          Assert.IsTrue(subscriber.WaitForCallback(1000));
        }
      }
    }
Пример #6
0
 public void TestThrowOnNotifyAtWithUnspecifiedDateTimeKind() {
   using(TestSubscriber subscriber = new TestSubscriber()) {
     using(Scheduler scheduler = new Scheduler()) {
       Assert.Throws<ArgumentException>(
         delegate() {
           scheduler.NotifyAt(new DateTime(2000, 1, 1), subscriber.Callback);
         }
       );
     }
   }
 }