-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ShouldExecuteHttpCallAsync -> PASS ShouldExecuteHttpCallAsync -> PASS ShouldExecuteHttpCallAsync -> PASS
- Loading branch information
1 parent
8ed3fe6
commit bacadf1
Showing
9 changed files
with
197 additions
and
5 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
RESTFulSense.Tests.Acceptance/Tests/RestfulApiClientTests.ExecuteHttpCall.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,49 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Newtonsoft.Json; | ||
using RESTFulSense.Tests.Acceptance.Models; | ||
using WireMock.RequestBuilders; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace RESTFulSense.Tests.Acceptance.Tests | ||
{ | ||
public partial class RestfulApiClientTests | ||
{ | ||
|
||
[Fact] | ||
private async Task ShouldExecuteHttpCallAsync() | ||
{ | ||
// given | ||
TEntity randomTEntity = GetRandomTEntity(); | ||
TEntity expectedTEntity = randomTEntity; | ||
var httpClient = new HttpClient(); | ||
httpClient.BaseAddress = new Uri(this.wiremockServer.Urls[0]); | ||
|
||
this.wiremockServer.Given(Request.Create() | ||
.WithPath(relativeUrl) | ||
.UsingGet()) | ||
.RespondWith(Response.Create() | ||
.WithStatusCode(200) | ||
.WithBodyAsJson(expectedTEntity)); | ||
|
||
// when | ||
HttpResponseMessage httpResponseMessage = | ||
await this.restfulApiClient.ExecuteHttpCallAsync( | ||
httpClient.GetAsync("/tests")); | ||
|
||
TEntity actualTEntityEntity = | ||
JsonConvert.DeserializeObject<TEntity>( | ||
await httpResponseMessage.Content.ReadAsStringAsync()); | ||
|
||
// then | ||
actualTEntityEntity.Should().BeEquivalentTo(expectedTEntity); | ||
} | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
RESTFulSense.Tests.Acceptance/Tests/RestfulSenseApiFactoryTests.ExecuteHttpCall.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,48 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Newtonsoft.Json; | ||
using RESTFulSense.Tests.Acceptance.Models; | ||
using WireMock.RequestBuilders; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace RESTFulSense.Tests.Acceptance.Tests | ||
{ | ||
public partial class RestfulSenseApiFactoryTests | ||
{ | ||
[Fact] | ||
private async Task ShouldExecuteHttpCallAsync() | ||
{ | ||
// given | ||
TEntity randomTEntity = GetRandomTEntity(); | ||
TEntity expectedTEntity = randomTEntity; | ||
var httpClient = new HttpClient(); | ||
httpClient.BaseAddress = new Uri(this.wiremockServer.Urls[0]); | ||
|
||
this.wiremockServer.Given(Request.Create() | ||
.WithPath(relativeUrl) | ||
.UsingGet()) | ||
.RespondWith(Response.Create() | ||
.WithStatusCode(200) | ||
.WithBodyAsJson(expectedTEntity)); | ||
|
||
// when | ||
HttpResponseMessage httpResponseMessage = | ||
await this.factoryClient.ExecuteHttpCallAsync( | ||
httpClient.GetAsync("/tests")); | ||
|
||
TEntity actualTEntityEntity = | ||
JsonConvert.DeserializeObject<TEntity>( | ||
await httpResponseMessage.Content.ReadAsStringAsync()); | ||
|
||
// then | ||
actualTEntityEntity.Should().BeEquivalentTo(expectedTEntity); | ||
} | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
...bAssenbly.Tests.Acceptance/Tests/RestfulSenseWebAssemblyApiClientTests.ExecuteHttpCall.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,48 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Newtonsoft.Json; | ||
using RESTFulSense.WebAssenbly.Tests.Acceptance.Models; | ||
using WireMock.RequestBuilders; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace RESTFulSense.WebAssenbly.Tests.Acceptance.Tests | ||
{ | ||
public partial class RestfulSenseWebAssemblyApiClientTests | ||
{ | ||
[Fact] | ||
private async Task ShouldExecuteHttpCallAsync() | ||
{ | ||
// given | ||
TEntity randomTEntity = GetRandomTEntity(); | ||
TEntity expectedTEntity = randomTEntity; | ||
var httpClient = new HttpClient(); | ||
httpClient.BaseAddress = new Uri(this.wiremockServer.Urls[0]); | ||
|
||
this.wiremockServer.Given(Request.Create() | ||
.WithPath(relativeUrl) | ||
.UsingGet()) | ||
.RespondWith(Response.Create() | ||
.WithStatusCode(200) | ||
.WithBodyAsJson(expectedTEntity)); | ||
|
||
// when | ||
HttpResponseMessage httpResponseMessage = | ||
await this.restfulWebAssemblyApiClient.ExecuteHttpCallAsync( | ||
httpClient.GetAsync("/tests")); | ||
|
||
TEntity actualTEntityEntity = | ||
JsonConvert.DeserializeObject<TEntity>( | ||
await httpResponseMessage.Content.ReadAsStringAsync()); | ||
|
||
// then | ||
actualTEntityEntity.Should().BeEquivalentTo(expectedTEntity); | ||
} | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
...ly.Tests.Acceptance/Tests/RestfulSenseWebAssemblyFactoryApiClientTests.ExecuteHttpCall.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,48 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// Copyright (c) The Standard Organization: A coalition of the Good-Hearted Engineers | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using Newtonsoft.Json; | ||
using RESTFulSense.WebAssenbly.Tests.Acceptance.Models; | ||
using WireMock.RequestBuilders; | ||
using WireMock.ResponseBuilders; | ||
using Xunit; | ||
|
||
namespace RESTFulSense.WebAssenbly.Tests.Acceptance.Tests | ||
{ | ||
public partial class RestfulSenseWebAssemblyFactoryApiClientTests | ||
{ | ||
[Fact] | ||
private async Task ShouldExecuteHttpCallAsync() | ||
{ | ||
// given | ||
TEntity randomTEntity = GetRandomTEntity(); | ||
TEntity expectedTEntity = randomTEntity; | ||
var httpClient = new HttpClient(); | ||
httpClient.BaseAddress = new Uri(this.wiremockServer.Urls[0]); | ||
|
||
this.wiremockServer.Given(Request.Create() | ||
.WithPath(relativeUrl) | ||
.UsingGet()) | ||
.RespondWith(Response.Create() | ||
.WithStatusCode(200) | ||
.WithBodyAsJson(expectedTEntity)); | ||
|
||
// when | ||
HttpResponseMessage httpResponseMessage = | ||
await this.webAssemblyApiFactoryClient.ExecuteHttpCallAsync( | ||
httpClient.GetAsync("/tests")); | ||
|
||
TEntity actualTEntityEntity = | ||
JsonConvert.DeserializeObject<TEntity>( | ||
await httpResponseMessage.Content.ReadAsStringAsync()); | ||
|
||
// then | ||
actualTEntityEntity.Should().BeEquivalentTo(expectedTEntity); | ||
} | ||
} | ||
} |
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