Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FluentAssertions extensions do not filter headers correctly #1074

Closed
chrischu opened this issue Mar 4, 2024 · 2 comments
Closed

FluentAssertions extensions do not filter headers correctly #1074

chrischu opened this issue Mar 4, 2024 · 2 comments
Assignees
Labels

Comments

@chrischu
Copy link

chrischu commented Mar 4, 2024

Describe the bug

When asserting headers via the FluentAssertions extensions, headers are not filtered correctly (headers from all captured requests are checked).

Expected behavior:

I expect the assertions to only consider the requests that match the previous filters (see example below).

Test to reproduce

[Test]
public async Task SendGetWithHeader ()
{
  using var server = WireMockServer.Start();
  using var httpClient = new HttpClient();

  // ACT
  await httpClient.GetAsync(server.Url!);

  var request = new HttpRequestMessage(HttpMethod.Post, server.Url!);
  request.Headers.Add("TestHeader", "Value");
  await httpClient.SendAsync(request);

  // ASSERT
  server.Should().HaveReceivedACall().UsingGet().And.WithHeader("TestHeader", "Value");
}

This test succeeds although it should fail, since only the POST request has the header, the GET request does not.

Other related info

I'm using WireMock.Net & WireMock.Net.FluentAssertions 1.5.48.

@chrischu chrischu added the bug label Mar 4, 2024
@StefH StefH self-assigned this Mar 4, 2024
@StefH
Copy link
Collaborator

StefH commented Mar 8, 2024

@chrischu
I can confirm this bug and it's fixed in preview version 1.5.49-ci-18411

https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@chrischu
Copy link
Author

chrischu commented Mar 8, 2024

Thanks for the quick fix!

@StefH StefH closed this as completed Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants