Skip to content

VerifyTests/Verify.Flurl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Verify.Flurl

Discussions Build status NuGet Status

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:

[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:

[
  {
    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

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages