Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:
zip -r ../transactionprocessoracl.zip ./*

- name: Upload the artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4.4.0
with:
name: transactionprocessoracl
path: transactionprocessoracl.zip
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:

steps:
- name: Download the artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4.1.8
with:
name: transactionprocessoracl

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- name: Run Integration Tests
run: dotnet test "TransactionProcessorACL.IntegrationTests\TransactionProcessorACL.IntegrationTests.csproj" --filter Category=PRTest

- uses: actions/upload-artifact@v2
- uses: actions/upload-artifact@v4.4.0
if: ${{ failure() }}
with:
name: tracelogs
Expand Down
71 changes: 33 additions & 38 deletions TransactionProcessorACL.BusinessLogic.Tests/MediatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SimpleResults;
using TransactionProcessorACL.Testing;
using Xunit;

Expand All @@ -26,12 +27,12 @@ public class MediatorTests

public MediatorTests()
{
this.Requests.Add(TestData.ProcessLogonTransactionRequest);
this.Requests.Add(TestData.ProcessReconciliationRequest);
this.Requests.Add(TestData.ProcessSaleTransactionRequest);
this.Requests.Add(TestData.VersionCheckRequest);
this.Requests.Add(TestData.GetVoucherRequest);
this.Requests.Add(TestData.RedeemVoucherRequest);
this.Requests.Add(TestData.ProcessLogonTransactionCommand);
this.Requests.Add(TestData.ProcessReconciliationCommand);
this.Requests.Add(TestData.ProcessSaleTransactionCommand);
this.Requests.Add(TestData.VersionCheckCommand);
this.Requests.Add(TestData.GetVoucherQuery);
this.Requests.Add(TestData.RedeemVoucherCommand);
}

[Fact]
Expand Down Expand Up @@ -99,38 +100,32 @@ private void AddTestRegistrations(ServiceRegistry services,

public class DummyTransactionProcessorACLApplicationService : ITransactionProcessorACLApplicationService
{
public async Task<ProcessLogonTransactionResponse> ProcessLogonTransaction(Guid estateId,
Guid merchantId,
DateTime transactionDateTime,
String transactionNumber,
String deviceIdentifier,
CancellationToken cancellationToken) {
return new ProcessLogonTransactionResponse();
}

public async Task<ProcessSaleTransactionResponse> ProcessSaleTransaction(Guid estateId,
Guid merchantId,
DateTime transactionDateTime,
String transactionNumber,
String deviceIdentifier,
Guid operatorId,
String customerEmailAddress,
Guid contractId,
Guid productId,
Dictionary<String, String> additionalRequestMetadata,
CancellationToken cancellationToken) {
return new ProcessSaleTransactionResponse();
}

public async Task<ProcessReconciliationResponse> ProcessReconciliation(Guid estateId,
Guid merchantId,
DateTime transactionDateTime,
String deviceIdentifier,
Int32 transactionCount,
Decimal transactionValue,
CancellationToken cancellationToken) {
return new ProcessReconciliationResponse();
}
public async Task<Result<ProcessLogonTransactionResponse>> ProcessLogonTransaction(Guid estateId,
Guid merchantId,
DateTime transactionDateTime,
String transactionNumber,
String deviceIdentifier,
CancellationToken cancellationToken) => Result.Success(new ProcessLogonTransactionResponse());

public async Task<Result<ProcessSaleTransactionResponse>> ProcessSaleTransaction(Guid estateId,
Guid merchantId,
DateTime transactionDateTime,
String transactionNumber,
String deviceIdentifier,
Guid operatorId,
String customerEmailAddress,
Guid contractId,
Guid productId,
Dictionary<String, String> additionalRequestMetadata,
CancellationToken cancellationToken) => Result.Success(new ProcessSaleTransactionResponse());

public async Task<Result<ProcessReconciliationResponse>> ProcessReconciliation(Guid estateId,
Guid merchantId,
DateTime transactionDateTime,
String deviceIdentifier,
Int32 transactionCount,
Decimal transactionValue,
CancellationToken cancellationToken) => Result.Success(new ProcessReconciliationResponse());

public async Task<GetVoucherResponse> GetVoucher(Guid estateId,
Guid contractId,
Expand Down
83 changes: 42 additions & 41 deletions TransactionProcessorACL.BusinessLogic.Tests/RequestHandlerTests.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using SimpleResults;

namespace TransactionProcessorACL.BusinesssLogic.Tests
{
using System;
Expand All @@ -15,6 +17,7 @@
using Shouldly;
using Testing;
using Xunit;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;

/// <summary>
///
Expand Down Expand Up @@ -51,16 +54,17 @@
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<CancellationToken>())).ReturnsAsync(TestData.ProcessLogonTransactionResponse);
ProcessLogonTransactionRequestHandler requestHandler = new ProcessLogonTransactionRequestHandler(applicationService.Object);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Object);

ProcessLogonTransactionRequest request = TestData.ProcessLogonTransactionRequest;
ProcessLogonTransactionResponse response = await requestHandler.Handle(request, CancellationToken.None);
TransactionCommands.ProcessLogonTransactionCommand command = TestData.ProcessLogonTransactionCommand;
Result<ProcessLogonTransactionResponse> result = await requestHandler.Handle(command, CancellationToken.None);

response.ShouldNotBeNull();
response.ResponseCode.ShouldBe(TestData.ResponseCode);
response.ResponseMessage.ShouldBe(TestData.ResponseMessage);
response.EstateId.ShouldBe(TestData.EstateId);
response.MerchantId.ShouldBe(TestData.MerchantId);
result.IsSuccess.ShouldBeTrue();
result.Data.ShouldNotBeNull();
result.Data.ResponseCode.ShouldBe(TestData.ResponseCode);
result.Data.ResponseMessage.ShouldBe(TestData.ResponseMessage);
result.Data.EstateId.ShouldBe(TestData.EstateId);
result.Data.MerchantId.ShouldBe(TestData.MerchantId);
}

[Fact]
Expand All @@ -80,14 +84,15 @@
It.IsAny<Dictionary<String,String>>(),
It.IsAny<CancellationToken>())).ReturnsAsync(TestData.ProcessSaleTransactionResponse);

ProcessSaleTransactionRequestHandler requestHandler = new ProcessSaleTransactionRequestHandler(applicationService.Object);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Object);

ProcessSaleTransactionRequest request = TestData.ProcessSaleTransactionRequest;
ProcessSaleTransactionResponse response = await requestHandler.Handle(request, CancellationToken.None);
TransactionCommands.ProcessSaleTransactionCommand command = TestData.ProcessSaleTransactionCommand;
Result<ProcessSaleTransactionResponse> result = await requestHandler.Handle(command, CancellationToken.None);

response.ShouldNotBeNull();
response.ResponseCode.ShouldBe(TestData.ResponseCode);
response.ResponseMessage.ShouldBe(TestData.ResponseMessage);
result.IsSuccess.ShouldBeTrue();
result.Data.ShouldNotBeNull();
result.Data.ResponseCode.ShouldBe(TestData.ResponseCode);
result.Data.ResponseMessage.ShouldBe(TestData.ResponseMessage);
}

[Fact]
Expand All @@ -102,52 +107,48 @@
It.IsAny<Int32>(),
It.IsAny<Decimal>(),
It.IsAny<CancellationToken>())).ReturnsAsync(TestData.ProcessReconciliationResponse);
ProcessReconciliationRequestHandler requestHandler = new ProcessReconciliationRequestHandler(applicationService.Object);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Object);

ProcessReconciliationRequest request = TestData.ProcessReconciliationRequest;
ProcessReconciliationResponse response = await requestHandler.Handle(request, CancellationToken.None);
TransactionCommands.ProcessReconciliationCommand command = TestData.ProcessReconciliationCommand;
Result<ProcessReconciliationResponse> result = await requestHandler.Handle(command, CancellationToken.None);

response.ShouldNotBeNull();
response.ResponseCode.ShouldBe(TestData.ResponseCode);
response.ResponseMessage.ShouldBe(TestData.ResponseMessage);
response.EstateId.ShouldBe(TestData.EstateId);
response.MerchantId.ShouldBe(TestData.MerchantId);
result.IsSuccess.ShouldBeTrue();
result.Data.ShouldNotBeNull();
result.Data.ResponseCode.ShouldBe(TestData.ResponseCode);
result.Data.ResponseMessage.ShouldBe(TestData.ResponseMessage);
result.Data.EstateId.ShouldBe(TestData.EstateId);
result.Data.MerchantId.ShouldBe(TestData.MerchantId);
}

[Fact]
public async Task VersionCheckRequestHandler_Handle_RequestIsHandled()
{
VersionCheckRequestHandler requestHandler = new VersionCheckRequestHandler();

VersionCheckRequest request = TestData.VersionCheckRequest;
Should.NotThrow(async () =>
{
await requestHandler.Handle(request, CancellationToken.None);
});
VersionCheckCommands.VersionCheckCommand command = TestData.VersionCheckCommand;
var result = await requestHandler.Handle(command, CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
}

[Fact]
public async Task VersionCheckRequestHandler_Handle_OldVersion_ErrorThrown()
{
VersionCheckRequestHandler requestHandler = new VersionCheckRequestHandler();

VersionCheckRequest request = VersionCheckRequest.Create(TestData.OldApplicationVersion);
Should.Throw<VersionIncompatibleException>(async () =>
{
await requestHandler.Handle(request, CancellationToken.None);
});

VersionCheckCommands.VersionCheckCommand command = new(TestData.OldApplicationVersion);
var result = await requestHandler.Handle(command, CancellationToken.None);
result.IsFailed.ShouldBeTrue();
result.Status.ShouldBe(ResultStatus.Conflict);
}

[Fact]
public async Task VersionCheckRequestHandler_Handle_NewerVersionBuildNumber_RequestIsHandled()
{
VersionCheckRequestHandler requestHandler = new VersionCheckRequestHandler();

VersionCheckRequest request = VersionCheckRequest.Create(TestData.NewerApplicationVersion);
Should.NotThrow(async () =>
{
await requestHandler.Handle(request, CancellationToken.None);
});

VersionCheckCommands.VersionCheckCommand command = new(TestData.NewerApplicationVersion);
var result = await requestHandler.Handle(command, CancellationToken.None);
result.IsSuccess.ShouldBeTrue(); ;

Check notice on line 151 in TransactionProcessorACL.BusinessLogic.Tests/RequestHandlerTests.cs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

TransactionProcessorACL.BusinessLogic.Tests/RequestHandlerTests.cs#L151

Remove this empty statement.
}

[Fact]
Expand All @@ -158,7 +159,7 @@

Should.NotThrow(async () =>
{
await requestHandler.Handle(TestData.GetVoucherRequest, CancellationToken.None);
await requestHandler.Handle(TestData.GetVoucherQuery, CancellationToken.None);
});
}

Expand All @@ -170,7 +171,7 @@

Should.NotThrow(async () =>
{
await requestHandler.Handle(TestData.RedeemVoucherRequest, CancellationToken.None);
await requestHandler.Handle(TestData.RedeemVoucherCommand, CancellationToken.None);
});
}

Expand Down
Loading
Loading