An open API service indexing awesome lists of open source software.

https://github.com/verifytests/verify.flurl


https://github.com/verifytests/verify.flurl

Last synced: about 1 year ago
JSON representation

Awesome Lists containing this project

README

          

# Verify.Flurl

[![Discussions](https://img.shields.io/badge/Verify-Discussions-yellow?svg=true&label=)](https://github.com/orgs/VerifyTests/discussions)
[![Build status](https://ci.appveyor.com/api/projects/status/rfmvbst3od5vpl7p?svg=true)](https://ci.appveyor.com/project/SimonCropp/verify-flurl)
[![NuGet Status](https://img.shields.io/nuget/v/Verify.Flurl.svg)](https://www.nuget.org/packages/Verify.Flurl/)

Extends [Verify](https://github.com/VerifyTests/Verify) to allow verification of [Flurl](https://flurl.dev/) bits.

**See [Milestones](../../milestones?state=closed) for release notes.**

## Sponsors

### Entity Framework Extensions

[Entity Framework Extensions](https://entityframework-extensions.net/) is a major sponsor and is proud to contribute to the development this project.

[![Entity Framework Extensions](docs/zzz.png)](https://entityframework-extensions.net)

## NuGet

* https://nuget.org/packages/Verify.Flurl

## Usage

### Initialize

Call `VerifyFlurl.Initialize()` in a `[ModuleInitializer]`.

```cs
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize() =>
VerifyFlurl.Initialize();
}
```

Alternatively, use `VerifierSettings.InitializePlugins()` to initialize all Verify plugins with default settings.

```cs
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Initialize() =>
VerifierSettings.InitializePlugins();
}
```

### Test

Given any calls to `HttpTest`, those call can be verified as follows:


```cs
[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);
}
```
snippet source | anchor

Results in:


```txt
[
{
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
}
}
}
]
```
snippet source | anchor