PageRenderTime 24ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 0ms

/System.Reactive.Tests/System.Reactive.Concurrency/EventLoopSchedulerTest.cs

https://github.com/gshackles/mono-reactive
C# | 31 lines | 30 code | 1 blank | 0 comment | 0 complexity | cbd125c9a266dc6b16ddd2b4874039ef MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Reactive;
  6. using System.Reactive.Concurrency;
  7. using System.Reactive.Disposables;
  8. using System.Reactive.Linq;
  9. using System.Threading;
  10. using NUnit.Framework;
  11. namespace System.Reactive.Concurrency.Tests
  12. {
  13. [TestFixture]
  14. public class EventSchedulerTest
  15. {
  16. [Test] // This test is (inevitably) processing speed dependent...
  17. public void Cancellation ()
  18. {
  19. bool raised = false;
  20. var s = new EventLoopScheduler ();
  21. var dis = s.Schedule<object> (null, TimeSpan.FromMilliseconds (300), (sch, stat) => {
  22. raised = true;
  23. return Disposable.Empty;
  24. });
  25. dis.Dispose (); // immediately dispose event => action should not run.
  26. Thread.Sleep (600);
  27. Assert.IsFalse (raised, "#1");
  28. }
  29. }
  30. }