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

CODE RUB: V2.10.3 Upgrade #53

Merged
merged 10 commits into from
Aug 4, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ private async Task ShouldRetrieveStatusDetailByStatusCodeAsync()
CreateRandomStatusDetail(randomStatusCodeValue);

this.errorBrokerMock.Setup(broker =>
broker.SelectAllStatusDetails())
.Returns(new List<StatusDetail> { expectedStatusDetail }
broker.SelectAllStatusDetailsAsync())
.ReturnsAsync(new List<StatusDetail> { expectedStatusDetail }
.AsQueryable());

// when
Expand All @@ -39,7 +39,7 @@ await errorMapperService.RetrieveStatusDetailByStatusCodeAsync(
actualStatusDetail.Should().BeEquivalentTo(expectedStatusDetail);

this.errorBrokerMock.Verify(broker =>
broker.SelectAllStatusDetails(), Times.Once);
broker.SelectAllStatusDetailsAsync(), Times.Once);

this.errorBrokerMock.VerifyNoOtherCalls();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ private async Task ShouldThrowValidationExceptionOnRetrieveIfStatusDetailNotFoun
innerException: notFoundErrorMapperException);

this.errorBrokerMock.Setup(broker =>
broker.SelectAllStatusDetails())
.Returns(new List<StatusDetail> { nullStatusDetail }.AsQueryable());
broker.SelectAllStatusDetailsAsync())
.ReturnsAsync(new List<StatusDetail> { nullStatusDetail }.AsQueryable());

// when
ValueTask<StatusDetail> retrieveStatusDetailByStatusCodeTask =
Expand All @@ -84,7 +84,7 @@ await Assert.ThrowsAsync<ErrorMapperValidationException>(() =>
expectedErrorMapperValidationException);

this.errorBrokerMock.Verify(broker =>
broker.SelectAllStatusDetails(), Times.Once);
broker.SelectAllStatusDetailsAsync(), Times.Once);

errorBrokerMock.VerifyNoOtherCalls();
}
Expand Down
5 changes: 3 additions & 2 deletions STX.REST.RESTFulSense.Clients/Brokers/Errors/ErrorBroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
// ----------------------------------------------------------------------------------

using System.Linq;
using System.Threading.Tasks;
using STX.REST.RESTFulSense.Clients.Models.Services.ErrorMappers;

namespace STX.REST.RESTFulSense.Clients.Brokers.Errors
{
internal partial class ErrorBroker : IErrorBroker
{
public IQueryable<StatusDetail> SelectAllStatusDetails() =>
statusDetails.AsQueryable();
public async ValueTask<IQueryable<StatusDetail>> SelectAllStatusDetailsAsync() =>
statusDetails.AsQueryable();
}
}
3 changes: 2 additions & 1 deletion STX.REST.RESTFulSense.Clients/Brokers/Errors/IErrorBroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
// ----------------------------------------------------------------------------------

using System.Linq;
using System.Threading.Tasks;
using STX.REST.RESTFulSense.Clients.Models.Services.ErrorMappers;

namespace STX.REST.RESTFulSense.Clients.Brokers.Errors
{
internal interface IErrorBroker
{
IQueryable<StatusDetail> SelectAllStatusDetails();
ValueTask<IQueryable<StatusDetail>> SelectAllStatusDetailsAsync();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>License.txt</PackageLicenseFile>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<NoWarn>CS1998</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ public ValueTask<StatusDetail> RetrieveStatusDetailByStatusCodeAsync(int statusC
{
ValidateStatusCode(statusCode);

StatusDetail statusDetail = errorBroker.SelectAllStatusDetails()
IQueryable<StatusDetail> statusDetails =
await errorBroker.SelectAllStatusDetailsAsync();

StatusDetail statusDetail = statusDetails
.FirstOrDefault(statusDetail =>
statusDetail != null && statusDetail.Code == statusCode);
statusDetail != null
&& statusDetail.Code == statusCode);

ValidateStatusDetail(statusDetail);

return await ValueTask.FromResult(statusDetail);
return statusDetail;
});
}
}
Loading