-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #165 from dncsvr/issue/dont-ensure-success
Issue / Don't Ensure Success
- Loading branch information
Showing
9 changed files
with
162 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/recipe/Baked.Test.Recipe.Service.Test/Communication/VerifyingClients.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using Baked.Communication; | ||
|
||
namespace Baked.Test.Communication; | ||
|
||
public class VerifyingClients : TestServiceSpec | ||
{ | ||
[Test] | ||
public async Task Verify_includes_parameters_only_when_given() | ||
{ | ||
var client = MockMe.TheClient<ExternalSamples>(); | ||
|
||
await client.Send(new("path", HttpMethod.Get)); | ||
await client.Send(new("path", HttpMethod.Get), allowErrorResponse: true); | ||
await client.Send(new Request("path", HttpMethod.Get).AddAuthorization("token")); | ||
await client.Send(new("path2", HttpMethod.Get)); | ||
await client.Send(new($"{GiveMe.AUrl()}", HttpMethod.Post, Content: new(new { content = "content" }))); | ||
await client.Send(new($"{GiveMe.AUrl()}", HttpMethod.Post, Content: new(new { content = "another content" }))); | ||
await client.Send(new($"{GiveMe.AUrl()}", HttpMethod.Post, Content: new(new() { { "Key", "Value" } }))); | ||
|
||
client.VerifySent(path: "path", times: 3); | ||
client.VerifySent(url: "path2", times: 1); | ||
client.VerifySent(allowErrorResponse: true, times: 1); | ||
client.VerifySent(method: HttpMethod.Get, times: 4); | ||
client.VerifySent(method: HttpMethod.Post, times: 3); | ||
client.VerifySent(content: new { content = "content" }, times: 1); | ||
client.VerifySent(contentContains: "content", times: 2); | ||
client.VerifySent(header: ("Authorization", "token"), times: 1); | ||
client.VerifySent(excludesHeader: "Authorization", times: 6); | ||
client.VerifySent(form: new() { { "Key", "Value" } }, times: 1); | ||
} | ||
|
||
[Test] | ||
public async Task Verify_must_satisfy_all_parameters_when_given() | ||
{ | ||
var client = MockMe.TheClient<ExternalSamples>(); | ||
|
||
await client.Send(new Request("path", HttpMethod.Get).AddAuthorization("token"), allowErrorResponse: true); | ||
await client.Send(new Request("path", HttpMethod.Post, Content: new(new { content = "another content" })).AddAuthorization("token"), allowErrorResponse: true); | ||
await client.Send(new Request("path", HttpMethod.Post, Content: new(new { content = "content" })).AddAuthorization("token"), allowErrorResponse: false); | ||
await client.Send(new Request("path", HttpMethod.Post, Content: new(new { content = "content" })).AddAuthorization("another token"), allowErrorResponse: true); | ||
await client.Send(new Request("another/path", HttpMethod.Post, Content: new(new { content = "content" })).AddAuthorization("token"), allowErrorResponse: true); | ||
await client.Send(new Request("path", HttpMethod.Post, Content: new(new { content = "content" })).AddAuthorization("token"), allowErrorResponse: true); | ||
|
||
client.VerifySent(path: "path", method: HttpMethod.Post, header: ("Authorization", "token"), content: new { content = "content" }, allowErrorResponse: true, times: 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
# Unreleased | ||
|
||
## Improvements | ||
|
||
- Change `Response.StatusCode` property type to `HttpStatusCode` | ||
- `VerifySent` now have `allowErrorResponse` parameter as optional | ||
- `MockMe.ThClient<T>` can now set response with only `statusCode` parameter | ||
|
||
## Bugfixes | ||
|
||
- `VerifySent` was throwing key not found exception when header key was not | ||
present, fixed |