O'Reilly logo

Programming Reactive Extensions and LINQ by Paul Betts, Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mocking Async Methods

Developers typically find it difficult to test asynchronous and timing-related methods. Unlike synchronous methods, it's not enough for an asynchronous method to simply return a correct value; you must also mimic the latency of its response.

There are many tools to test synchronous methods, but testing their asynchronous cousins is tricky. Developers often use Thread.Sleep() to simulate a long-running method, but the method only influences the timing to a very rough approximation but still doesn't let you actually control the timing with any precision.

One of the core innovations of Rx is its orchestration of events over time. We've already used operators such as Timeout, Delay, and Window, to manipulate streams based on ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required