Skip to content

Commit

Permalink
Merge pull request #53 from The-Standard-Organization/users/aosunlana…
Browse files Browse the repository at this point in the history
…/coderub-update-to-standard-v2103

CODE RUB: V2.10.3 Upgrade
  • Loading branch information
glhays authored Aug 4, 2024
2 parents 094340d + 10fc47e commit dc23337
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
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;
});
}
}

0 comments on commit dc23337

Please sign in to comment.