Helpers for async unit testing.
C# PowerShell
Permalink
Failed to load latest commit information.
Nito.AsyncEx.UnitTests/MSFakes
.gitignore
AsyncExUnitTests.128.png
LICENSE
README.md

README.md

logo

Async-Aware Default Stub Behavior for Microsoft Fakes

The built-in default stub behavior for Microsoft Fakes will return null tasks from asynchronous methods. The Nito.AsyncEx.UnitTests.MSFakes NuGet package provides the AsyncAwareDefaultValueStubBehavior type.

Recommended usage is to apply the async-aware default stub behavior to all unit tests in a project:

[AssemblyInitialize]
public static void Initialize(TestContext context)
{
  StubBehaviors.Current = new Nito.Async.UnitTests.AsyncAwareDefaultValueStubBehavior();
}

However, it can be set on a test-by-test basis:

var stub = new Stub...;
stub.InstanceBehavior = new Nito.Async.UnitTests.AsyncAwareDefaultValueStubBehavior();