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
11 changes: 11 additions & 0 deletions TransactionProcessorACL.BusinessLogic.Tests/MediatorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace TransactionProcessorACL.BusinessLogic.Tests
{
using System.Threading;
using Microsoft.Extensions.DependencyInjection;
using TransactionProcessorACL.BusinessLogic.Requests;
using TransactionProcessorACL.DataTransferObjects.Requests;
using Models;
using Services;
Expand All @@ -40,6 +41,7 @@ public MediatorTests()
this.Requests.Add(TestData.GetMerchantDailyPerformanceSummaryQuery);
this.Requests.Add(TestData.GetMerchantTransactionMixSummaryQuery);
this.Requests.Add(TestData.GetRecentActivityReceiptSearchQuery);
this.Requests.Add(new TransactionCommands.ResendReceiptCommand(TestData.EstateId, TestData.MerchantId, "RCPT-0001", "recipient@example.com"));
}

[Fact]
Expand Down Expand Up @@ -185,5 +187,14 @@ public async Task<Result<RecentActivityReceiptSearchResponse>> GetRecentActivity
{
return Result.Success(new RecentActivityReceiptSearchResponse());
}

public async Task<Result<ResendReceiptResponse>> ResendReceipt(Guid estateId,
Guid merchantId,
String reference,
String recipientEmailAddress,
CancellationToken cancellationToken)
{
return Result.Success(new ResendReceiptResponse { Success = true, Message = "Receipt resend requested." });
}
}
}
27 changes: 27 additions & 0 deletions TransactionProcessorACL.BusinessLogic.Tests/RequestHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,33 @@ public async Task ReportingRequestHandler_GetRecentActivityReceiptSearchQuery_Ha
result.Data.ShouldNotBeNull();
}

[Fact]
public async Task TransactionRequestHandler_ResendReceiptCommand_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
applicationService
.Setup(a => a.ResendReceipt(It.IsAny<Guid>(),
It.IsAny<Guid>(),
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<CancellationToken>()))
.ReturnsAsync(new ResendReceiptResponse { Success = true, Message = "Receipt resend requested." });

TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Object);

TransactionCommands.ResendReceiptCommand command = new(
TestData.EstateId,
TestData.MerchantId,
"RCPT-0001",
"recipient@example.com");

Result<ResendReceiptResponse> result = await requestHandler.Handle(command, CancellationToken.None);

result.IsSuccess.ShouldBeTrue();
result.Data.ShouldNotBeNull();
result.Data.Success.ShouldBeTrue();
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ namespace TransactionProcessorACL.BusinessLogic.RequestHandlers
/// <seealso cref="ProcessLogonTransactionResponse" />
public class TransactionRequestHandler : IRequestHandler<TransactionCommands.ProcessLogonTransactionCommand, Result<ProcessLogonTransactionResponse>>,
IRequestHandler<TransactionCommands.ProcessReconciliationCommand, Result<ProcessReconciliationResponse>>,
IRequestHandler<TransactionCommands.ProcessSaleTransactionCommand, Result<ProcessSaleTransactionResponse>>
IRequestHandler<TransactionCommands.ProcessSaleTransactionCommand, Result<ProcessSaleTransactionResponse>>,
IRequestHandler<TransactionCommands.ResendReceiptCommand, Result<ResendReceiptResponse>>
{
#region Fields

Expand Down Expand Up @@ -62,7 +63,7 @@ public async Task<Result<ProcessReconciliationResponse>> Handle(TransactionComma
}

public async Task<Result<ProcessSaleTransactionResponse>> Handle(TransactionCommands.ProcessSaleTransactionCommand command,
CancellationToken cancellationToken)
CancellationToken cancellationToken)
{
return await this.ApplicationService.ProcessSaleTransaction((command.EstateId, command.MerchantId),
command.TransactionDateTime,
Expand All @@ -74,6 +75,16 @@ public async Task<Result<ProcessSaleTransactionResponse>> Handle(TransactionComm
cancellationToken);
}

public async Task<Result<ResendReceiptResponse>> Handle(TransactionCommands.ResendReceiptCommand command,
CancellationToken cancellationToken)
{
return await this.ApplicationService.ResendReceipt(command.EstateId,
command.MerchantId,
command.Reference,
command.RecipientEmailAddress,
cancellationToken);
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,10 @@ public record ProcessReconciliationCommand(Guid EstateId,
Int32 TransactionCount,
Decimal TransactionValue)
: IRequest<Result<ProcessReconciliationResponse>>;

public record ResendReceiptCommand(Guid EstateId,
Guid MerchantId,
String Reference,
String RecipientEmailAddress)
: IRequest<Result<ResendReceiptResponse>>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,11 @@ Task<Result<MerchantTransactionMixSummaryResponse>> GetMerchantTransactionMixSum
Task<Result<RecentActivityReceiptSearchResponse>> GetRecentActivityReceiptSearch(Guid estateId,
RecentActivityReceiptSearchRequest request,
CancellationToken cancellationToken);

Task<Result<ResendReceiptResponse>> ResendReceipt(Guid estateId,
Guid merchantId,
String reference,
String recipientEmailAddress,
CancellationToken cancellationToken);
}
}
Loading
Loading