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