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 ...
Get Programming Reactive Extensions and LINQ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.