예제 #1
0
        public void TestWaitTimeSpan()
        {
            TestTransaction test = new TestTransaction();

            // Wait 0 milliseconds for the transaction to end. Of course, this will not happen,
            // so a timeout occurs and false is returned
            Assert.IsFalse(test.Wait(TimeSpan.Zero));

            test.End();

            // Wait another 0 milliseconds for the transaction to end. Now it has already ended
            // and no timeout will occur, even with a wait time of 0 milliseconds.
            Assert.IsTrue(test.Wait(TimeSpan.Zero));
        }
예제 #2
0
        public void TestWaitUnlimited()
        {
            TestTransaction test = new TestTransaction();

            // We can only do a positive test here without slowing down the unit test
            ThreadPool.QueueUserWorkItem(
                (WaitCallback) delegate(object state) { Thread.Sleep(1); test.End(); }
                );

            test.Wait();
        }
예제 #3
0
    public void TestWaitTimeSpan() {
      TestTransaction test = new TestTransaction();

      // Wait 0 milliseconds for the transaction to end. Of course, this will not happen,
      // so a timeout occurs and false is returned
      Assert.IsFalse(test.Wait(TimeSpan.Zero));

      test.End();

      // Wait another 0 milliseconds for the transaction to end. Now it has already ended
      // and no timeout will occur, even with a wait time of 0 milliseconds.
      Assert.IsTrue(test.Wait(TimeSpan.Zero));
    }
예제 #4
0
    public void TestWaitUnlimited() {
      TestTransaction test = new TestTransaction();

      // We can only do a positive test here without slowing down the unit test
      ThreadPool.QueueUserWorkItem(
        (WaitCallback)delegate(object state) { Thread.Sleep(1); test.End(); }
      );

      test.Wait();
    }