TimerTest.cs 695 B

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // TimerTest.cs - NUnit test cases for System.Threading.Timer
  3. //
  4. // Author:
  5. // Zoltan Varga ([email protected])
  6. //
  7. // (C) 2004 Novell, Inc (http://www.novell.com)
  8. //
  9. using NUnit.Framework;
  10. using System;
  11. using System.Threading;
  12. namespace MonoTests.System.Threading {
  13. [TestFixture]
  14. public class TimerTest : Assertion {
  15. public int counter;
  16. private void Callback (object foo) {
  17. counter ++;
  18. }
  19. public void TestZeroDueTime () {
  20. counter = 0;
  21. Timer t = new Timer (new TimerCallback (Callback), null, 0, Timeout.Infinite);
  22. Thread.Sleep (100);
  23. AssertEquals (1, counter);
  24. t.Change (0, Timeout.Infinite);
  25. Thread.Sleep (100);
  26. AssertEquals (2, counter);
  27. }
  28. }
  29. }