Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bcfe053
commit 631fcb2
Showing
1 changed file
with
13 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
AsyncUnitTests | ||
============== | ||
|
||
Helpers for async unit testing. | ||
![logo](https://github.com/StephenCleary/AsyncUnitTests/raw/master/AsyncExUnitTests.128.png) | ||
|
||
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](https://www.nuget.org/packages/Nito.AsyncEx.UnitTests.MSFakes/) 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(); | ||
} | ||
````C# | ||
[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(); | ||
````C# | ||
var stub = new Stub...; | ||
stub.InstanceBehavior = new Nito.Async.UnitTests.AsyncAwareDefaultValueStubBehavior(); | ||
```` |