Skip to content

Commit

Permalink
ShouldExecuteHttpCallAsync -> PASS
Browse files Browse the repository at this point in the history
ShouldExecuteHttpCallAsync -> PASS
ShouldExecuteHttpCallAsync -> PASS
ShouldExecuteHttpCallAsync -> PASS
  • Loading branch information
hassanhabib committed Apr 28, 2024
1 parent 8ed3fe6 commit bacadf1
Show file tree
Hide file tree
Showing 9 changed files with 197 additions and 5 deletions.
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public partial class RestfulApiClientTests
{

[Fact]
private async Task ShouldPostContentWithNoResponseAndDeserializeContentAsync()
private void ShouldPostContentWithNoResponseAndDeserializeContent()
{
// given
TEntity randomTEntity = GetRandomTEntity();
Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ await this.factoryClient.PostContentWithNoResponseAsync<TEntity>(
}

[Fact]
private async Task ShouldPostContentWithNoResponseAndDeserializeContentAsync()
private void ShouldPostContentWithNoResponseAndDeserializeContent()
{
// given
TEntity randomTEntity = GetRandomTEntity();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Threading;
using System.Threading.Tasks;
using FluentAssertions;
using Newtonsoft.Json;
using RESTFulSense.Tests.Acceptance.Models;
using WireMock.RequestBuilders;
using WireMock.ResponseBuilders;
Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace RESTFulSense.WebAssenbly.Tests.Acceptance.Tests
public partial class RestfulSenseWebAssemblyApiClientTests
{
[Fact]
private async Task ShouldPostContentWithNoResponseAndDeserializeContentAsync()
private void ShouldPostContentWithNoResponseAndDeserializeContent()
{
// given
TEntity randomTEntity = GetRandomTEntity();
Expand Down
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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace RESTFulSense.WebAssenbly.Tests.Acceptance.Tests
public partial class RestfulSenseWebAssemblyFactoryApiClientTests
{
[Fact]
private async Task ShouldPostContentWithNoResponseAndDeserializeContentAsync()
private void ShouldPostContentWithNoResponseAndDeserializeContent()
{
// given
TEntity randomTEntity = GetRandomTEntity();
Expand Down

0 comments on commit bacadf1

Please sign in to comment.