Awesome
<img src="/src/icon.png" height="30px"> Verify.Flurl
Extends Verify to allow verification of Flurl bits.
See Milestones for release notes.
NuGet package
https://nuget.org/packages/Verify.Flurl/
Usage
Initialize
Call VerifyFlurl.Initialize()
in a [ModuleInitializer]
.
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize() =>
VerifyFlurl.Initialize();
}
Alternatively, use VerifierSettings.InitializePlugins()
to initialize all Verify plugins with default settings.
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize() =>
VerifierSettings.InitializePlugins();
}
Test
Given any calls to HttpTest
, those call can be verified as follows:
<a id='snippet-usage'></a>
[Fact]
public async Task Usage()
{
using var httpTest = new HttpTest();
httpTest.RespondWith("OK");
await "http://api.mysite.com/".GetAsync();
await "http://api.mysite.com/".PostAsync(new StringContent("the content"));
await Verify(httpTest);
}
<sup><a href='/src/Tests/Tests.cs#L3-L18' title='Snippet source file'>snippet source</a> | <a href='#snippet-usage' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->Results in:
<!-- snippet: Tests.Usage.verified.txt --><a id='snippet-Tests.Usage.verified.txt'></a>
[
{
Request: http://api.mysite.com/,
Response: {
Status: 200 OK,
Content: {
Headers: {
Content-Type: text/plain; charset=utf-8
},
Value: OK
}
}
},
{
Request: {
Method: POST,
Uri: http://api.mysite.com/,
Content: {
Headers: {
Content-Type: text/plain; charset=utf-8
},
Value: the content
}
},
Response: {
Status: 200 OK,
Content: {
Headers: {
Content-Type: text/plain; charset=utf-8
},
Value: OK
}
}
}
]
<sup><a href='/src/Tests/Tests.Usage.verified.txt#L1-L35' title='Snippet source file'>snippet source</a> | <a href='#snippet-Tests.Usage.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->