Getting started
Installation
-
Install the
aweXpectnuget packagedotnet add package aweXpect -
Add the following
usingstatement:using aweXpect;This brings the static
Expectclass and lots of extension methods into scope. -
Simplify expectations (optional)
If you want to simplify the assertions, you can add aglobal using static aweXpect.Expect;statement anywhere in your test project. This allows writing a more concise syntax:// ↓ Default behaviourawait Expect.That(subject).IsTrue();await That(subject).IsTrue();// ↑ With global static
Write your first expectation
Write your first expectation:
[Fact]
public async Task IsInLibrary_WhenAlbumIsMissing_ShouldReturnFalse()
{
bool result = IsInLibrary("Unknown Album");
await Expect.That(result).IsFalse();
}
If it fails, it will throw a framework-specific exception with the following message:
Expected result tobe False,but it was True
Add a reason
You can add a reason for all expectations, that will be included in the exception message:
[Fact]
public async Task IsInLibrary_WhenAlbumIsMissing_ShouldReturnFalse()
{
bool result = IsInLibrary("Unknown Album");
await Expect.That(result).IsFalse().Because("the album is not in the library");
}
This will result in
Expected result tobe False, because the album is not in the library,but it was True