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 Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="2.3.3" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="10.0.2" />
<PackageVersion Include="Moq" Version="4.20.72" />
<PackageVersion Include="Imposter" Version="0.1.9" />
<PackageVersion Include="NLog.Extensions.Logging" Version="6.2.0" />
<PackageVersion Include="NUnit" Version="4.6.1" />
<PackageVersion Include="NUnit3TestAdapter" Version="6.3.0" />
Expand All @@ -55,4 +55,4 @@
<PackageVersion Include="xunit.v3" Version="4.0.0" />
<PackageVersion Include="xunit.runner.visualstudio" Version="4.0.0" />
</ItemGroup>
</Project>
</Project>
12 changes: 12 additions & 0 deletions TransactionProcessorACL.BusinessLogic.Tests/ImposterGeneration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Imposter.Abstractions;
using Microsoft.AspNetCore.Hosting;
using SecurityService.Client;
using TransactionProcessor.Client;
using TransactionProcessorACL.BusinessLogic.BackendAPI;
using TransactionProcessorACL.BusinessLogic.Services;

[assembly: GenerateImposter(typeof(ITransactionProcessorClient))]
[assembly: GenerateImposter(typeof(ISecurityServiceClient))]
[assembly: GenerateImposter(typeof(IEstateReportingApiClient))]
[assembly: GenerateImposter(typeof(ITransactionProcessorACLApplicationService))]
[assembly: GenerateImposter(typeof(IWebHostEnvironment))]
16 changes: 8 additions & 8 deletions TransactionProcessorACL.BusinessLogic.Tests/MediatorTests.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Lamar;
using Lamar;
using MediatR;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
using Moq;
using Imposter.Abstractions;
using System;
using System.Collections.Generic;
using System.Diagnostics;
Expand Down Expand Up @@ -47,16 +47,16 @@ public MediatorTests()
[Fact]
public async Task Mediator_Send_RequestHandled()
{
Mock<IWebHostEnvironment> hostingEnvironment = new Mock<IWebHostEnvironment>();
hostingEnvironment.Setup(he => he.EnvironmentName).Returns("Development");
hostingEnvironment.Setup(he => he.ContentRootPath).Returns("/home");
hostingEnvironment.Setup(he => he.ApplicationName).Returns("Test Application");
var hostingEnvironment = new IWebHostEnvironmentImposter(ImposterMode.Explicit);
hostingEnvironment.EnvironmentName.Getter().Returns("Development");
hostingEnvironment.ContentRootPath.Getter().Returns("/home");
hostingEnvironment.ApplicationName.Getter().Returns("Test Application");

ServiceRegistry services = new ServiceRegistry();
Startup s = new Startup(hostingEnvironment.Object);
Startup s = new Startup(hostingEnvironment.Instance());
Startup.Configuration = this.SetupMemoryConfiguration();

this.AddTestRegistrations(services, hostingEnvironment.Object);
this.AddTestRegistrations(services, hostingEnvironment.Instance());
s.ConfigureContainer(services);

List<String> errors = new List<String>();
Expand Down
108 changes: 54 additions & 54 deletions TransactionProcessorACL.BusinessLogic.Tests/RequestHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace TransactionProcessorACL.BusinesssLogic.Tests
using BusinessLogic.Services;
using Microsoft.Extensions.Configuration;
using Models;
using Moq;
using Imposter.Abstractions;
using Shared.General;
using Shouldly;
using Testing;
Expand Down Expand Up @@ -49,15 +49,15 @@ private void SetupMemoryConfiguration()
[Fact]
public async Task ProcessLogonTransactionRequestHandler_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.ProcessLogonTransaction(It.IsAny<Guid>(),
It.IsAny<Guid>(),
It.IsAny<DateTime>(),
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<CancellationToken>())).ReturnsAsync(TestData.ProcessLogonTransactionResponse);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Object);
.ProcessLogonTransaction(Arg<Guid>.Any(),
Arg<Guid>.Any(),
Arg<DateTime>.Any(),
Arg<String>.Any(),
Arg<String>.Any(),
Arg<CancellationToken>.Any()).ReturnsAsync(TestData.ProcessLogonTransactionResponse);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Instance());

TransactionCommands.ProcessLogonTransactionCommand command = TestData.ProcessLogonTransactionCommand;
Result<ProcessLogonTransactionResponse> result = await requestHandler.Handle(command, CancellationToken.None);
Expand All @@ -73,18 +73,18 @@ public async Task ProcessLogonTransactionRequestHandler_Handle_RequestIsHandled(
[Fact]
public async Task ProcessSaleTransactionRequestHandler_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.ProcessSaleTransaction(It.IsAny<(Guid, Guid)>(),
It.IsAny<DateTime>(),
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<(Guid, Guid, Guid)>(),
It.IsAny<Dictionary<String,String>>(),
It.IsAny<CancellationToken>())).ReturnsAsync(TestData.ProcessSaleTransactionResponse);
.ProcessSaleTransaction(Arg<(Guid, Guid)>.Any(),
Arg<DateTime>.Any(),
Arg<String>.Any(),
Arg<String>.Any(),
Arg<String>.Any(),
Arg<(Guid, Guid, Guid)>.Any(),
Arg<Dictionary<String,String>>.Any(),
Arg<CancellationToken>.Any()).ReturnsAsync(TestData.ProcessSaleTransactionResponse);

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

TransactionCommands.ProcessSaleTransactionCommand command = TestData.ProcessSaleTransactionCommand;
Result<ProcessSaleTransactionResponse> result = await requestHandler.Handle(command, CancellationToken.None);
Expand All @@ -98,16 +98,16 @@ public async Task ProcessSaleTransactionRequestHandler_Handle_RequestIsHandled()
[Fact]
public async Task ProcessReconciliationRequestHandler_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.ProcessReconciliation(It.IsAny<Guid>(),
It.IsAny<Guid>(),
It.IsAny<DateTime>(),
It.IsAny<String>(),
It.IsAny<Int32>(),
It.IsAny<Decimal>(),
It.IsAny<CancellationToken>())).ReturnsAsync(TestData.ProcessReconciliationResponse);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Object);
.ProcessReconciliation(Arg<Guid>.Any(),
Arg<Guid>.Any(),
Arg<DateTime>.Any(),
Arg<String>.Any(),
Arg<Int32>.Any(),
Arg<Decimal>.Any(),
Arg<CancellationToken>.Any()).ReturnsAsync(TestData.ProcessReconciliationResponse);
TransactionRequestHandler requestHandler = new TransactionRequestHandler(applicationService.Instance());

TransactionCommands.ProcessReconciliationCommand command = TestData.ProcessReconciliationCommand;
Result<ProcessReconciliationResponse> result = await requestHandler.Handle(command, CancellationToken.None);
Expand Down Expand Up @@ -178,8 +178,8 @@ public async Task VersionCheckRequestHandler_Handle_NullVersionInRequest_Request
[Fact]
public async Task VoucherRequestHandler_GetVoucherRequest_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
VoucherRequestHandler requestHandler = new VoucherRequestHandler(applicationService.Object);
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
VoucherRequestHandler requestHandler = new VoucherRequestHandler(applicationService.Instance());

Should.NotThrow(async () =>
{
Expand All @@ -190,8 +190,8 @@ public async Task VoucherRequestHandler_GetVoucherRequest_Handle_RequestIsHandle
[Fact]
public async Task VoucherRequestHandler_RedeemVoucherRequest_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
VoucherRequestHandler requestHandler = new VoucherRequestHandler(applicationService.Object);
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
VoucherRequestHandler requestHandler = new VoucherRequestHandler(applicationService.Instance());

Should.NotThrow(async () =>
{
Expand All @@ -202,14 +202,14 @@ public async Task VoucherRequestHandler_RedeemVoucherRequest_Handle_RequestIsHan
[Fact]
public async Task ReportingRequestHandler_GetMerchantTransactionMixSummaryQuery_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.GetMerchantTransactionMixSummary(It.IsAny<Guid>(),
It.IsAny<MerchantTransactionMixSummaryRequest>(),
It.IsAny<CancellationToken>()))
.GetMerchantTransactionMixSummary(Arg<Guid>.Any(),
Arg<MerchantTransactionMixSummaryRequest>.Any(),
Arg<CancellationToken>.Any())
.ReturnsAsync(new MerchantTransactionMixSummaryResponse());

ReportingRequestHandler requestHandler = new ReportingRequestHandler(applicationService.Object);
ReportingRequestHandler requestHandler = new ReportingRequestHandler(applicationService.Instance());

ReportingQueries.GetMerchantTransactionMixSummaryQuery query = new(
TestData.EstateId,
Expand All @@ -232,14 +232,14 @@ public async Task ReportingRequestHandler_GetMerchantTransactionMixSummaryQuery_
[Fact]
public async Task ReportingRequestHandler_GetMerchantDailyPerformanceSummaryQuery_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.GetMerchantDailyPerformanceSummary(It.IsAny<Guid>(),
It.IsAny<MerchantDailyPerformanceSummaryRequest>(),
It.IsAny<CancellationToken>()))
.GetMerchantDailyPerformanceSummary(Arg<Guid>.Any(),
Arg<MerchantDailyPerformanceSummaryRequest>.Any(),
Arg<CancellationToken>.Any())
.ReturnsAsync(new MerchantDailyPerformanceSummaryResponse());

ReportingRequestHandler requestHandler = new ReportingRequestHandler(applicationService.Object);
ReportingRequestHandler requestHandler = new ReportingRequestHandler(applicationService.Instance());

ReportingQueries.GetMerchantDailyPerformanceSummaryQuery query = new(
TestData.EstateId,
Expand All @@ -259,14 +259,14 @@ public async Task ReportingRequestHandler_GetMerchantDailyPerformanceSummaryQuer
[Fact]
public async Task ReportingRequestHandler_GetRecentActivityReceiptSearchQuery_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.GetRecentActivityReceiptSearch(It.IsAny<Guid>(),
It.IsAny<RecentActivityReceiptSearchRequest>(),
It.IsAny<CancellationToken>()))
.GetRecentActivityReceiptSearch(Arg<Guid>.Any(),
Arg<RecentActivityReceiptSearchRequest>.Any(),
Arg<CancellationToken>.Any())
.ReturnsAsync(new RecentActivityReceiptSearchResponse());

ReportingRequestHandler requestHandler = new ReportingRequestHandler(applicationService.Object);
ReportingRequestHandler requestHandler = new ReportingRequestHandler(applicationService.Instance());

ReportingQueries.GetRecentActivityReceiptSearchQuery query = new(
TestData.EstateId,
Expand All @@ -288,16 +288,16 @@ public async Task ReportingRequestHandler_GetRecentActivityReceiptSearchQuery_Ha
[Fact]
public async Task TransactionRequestHandler_ResendReceiptCommand_Handle_RequestIsHandled()
{
Mock<ITransactionProcessorACLApplicationService> applicationService = new Mock<ITransactionProcessorACLApplicationService>();
ITransactionProcessorACLApplicationServiceImposter applicationService = new ITransactionProcessorACLApplicationServiceImposter();
applicationService
.Setup(a => a.ResendReceipt(It.IsAny<Guid>(),
It.IsAny<Guid>(),
It.IsAny<String>(),
It.IsAny<String>(),
It.IsAny<CancellationToken>()))
.ResendReceipt(Arg<Guid>.Any(),
Arg<Guid>.Any(),
Arg<String>.Any(),
Arg<String>.Any(),
Arg<CancellationToken>.Any())
.ReturnsAsync(new ResendReceiptResponse { Success = true, Message = "Receipt resend requested." });

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

TransactionCommands.ResendReceiptCommand command = new(
TestData.EstateId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="Moq" Version="4.16.0" />
<PackageReference Include="Imposter" />
<PackageReference Include="Shouldly" Version="4.0.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="MediatR" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="Imposter" />
<PackageReference Include="Shouldly" />
<PackageReference Include="Microsoft.Testing.Extensions.TrxReport" />
<PackageReference Include="TransactionProcessor.Client" />
Expand Down
Loading
Loading