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
1 change: 1 addition & 0 deletions .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"
dotnet test "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests.csproj"

- name: Build Docker Images
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jobs:
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov2.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"
dotnet test "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov3.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"

- name: Setup Node.js for use with actions
uses: actions/setup-node@v1.1.0
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"
dotnet test "TransactionProcessor.TransactionAggregate.Tests\TransactionProcessor.TransactionAggregate.Tests.csproj"

- name: Build Docker Image
run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace TransactionProcessor.BusinessLogic.Tests.CommandHandler
using System.Threading;
using System.Threading.Tasks;
using BusinessLogic.Commands;
using BusinessLogic.Services;
using CommandHandlers;
using Commands;
using Moq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System.Threading;
using BusinessLogic.Commands;
using BusinessLogic.Services;
using CommandHandlers;
using Commands;
using Moq;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class CommandTests
[Fact]
public void ProcessLogonTransactionCommand_CanBeCreated_IsCreated()
{
ProcessLogonTransactionCommand processLogonTransactionCommand = ProcessLogonTransactionCommand.Create(TestData.EstateId, TestData.MerchantId, TestData.IMEINumber,TestData.TransactionType, TestData.TransactionDateTime,
ProcessLogonTransactionCommand processLogonTransactionCommand = ProcessLogonTransactionCommand.Create(TestData.TransactionId, TestData.EstateId, TestData.MerchantId, TestData.IMEINumber,TestData.TransactionType, TestData.TransactionDateTime,
TestData.TransactionNumber);

processLogonTransactionCommand.ShouldNotBeNull();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TransactionProcessor.BusinessLogic.Tests.Services
{
using System.Threading;
using System.Threading.Tasks;
using BusinessLogic.Services;
using Models;
using Moq;
using Shared.DomainDrivenDesign.EventStore;
using Shared.EventStore.EventStore;
using Shouldly;
using Testing;
using TransactionAggregate;
using Xunit;

public class TransactionDomainServiceTests
{
[Fact]
public async Task TransactionDomainService_ProcessLogonTransaction_TransactionIsProcessed()
{
Mock<IAggregateRepositoryManager> aggregateRepositoryManager = new Mock<IAggregateRepositoryManager>();
Mock<IAggregateRepository<TransactionAggregate>> transactionAggregateRepository = new Mock<IAggregateRepository<TransactionAggregate>>();

aggregateRepositoryManager.Setup(x => x.GetAggregateRepository<TransactionAggregate>(It.IsAny<Guid>())).Returns(transactionAggregateRepository.Object);
transactionAggregateRepository.SetupSequence(t => t.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
.ReturnsAsync(TestData.GetEmptyTransactionAggregate)
.ReturnsAsync(TestData.GetStartedTransactionAggregate)
.ReturnsAsync(TestData.GetLocallyAuthorisedTransactionAggregate)
.ReturnsAsync(TestData.GetCompletedTransactionAggregate);
transactionAggregateRepository.Setup(t => t.SaveChanges(It.IsAny<TransactionAggregate>(), It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);

TransactionDomainService transactionDomainService = new TransactionDomainService(aggregateRepositoryManager.Object);

ProcessLogonTransactionResponse response = await transactionDomainService.ProcessLogonTransaction(TestData.TransactionId,
TestData.EstateId,
TestData.MerchantId,
TestData.TransactionDateTime,
TestData.TransactionNumber,
TestData.IMEINumber,
CancellationToken.None);

response.ShouldNotBeNull();
response.ResponseCode.ShouldBe(TestData.ResponseCode);
response.ResponseMessage.ShouldBe(TestData.ResponseMessage);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

<ItemGroup>
<Folder Include="Manager\" />
<Folder Include="Services\" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public async Task Handle(ICommand command,
private async Task HandleCommand(ProcessLogonTransactionCommand command,
CancellationToken cancellationToken)
{
ProcessLogonTransactionResponse logonResponse = await this.TransactionDomainService.ProcessLogonTransaction(cancellationToken);
ProcessLogonTransactionResponse logonResponse = await this.TransactionDomainService.ProcessLogonTransaction(command.TransactionId, command.EstateId,
command.MerchantId, command.TransactionDateTime, command.TransactionNumber, command.IMEINumber, cancellationToken);

command.Response = logonResponse;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
/// <seealso cref="Shared.DomainDrivenDesign.CommandHandling.Command{TransactionProcessor.Models.ProcessLogonTransactionResponse}" />
public class ProcessLogonTransactionCommand : Command<ProcessLogonTransactionResponse>
{
public Guid TransactionId { get; private set; }

#region Constructors

/// <summary>
Expand All @@ -22,14 +24,16 @@ public class ProcessLogonTransactionCommand : Command<ProcessLogonTransactionRes
/// <param name="transactionDateTime">The transaction date time.</param>
/// <param name="transactionNumber">The transaction number.</param>
/// <param name="commandId">The command identifier.</param>
private ProcessLogonTransactionCommand(Guid estateId,
private ProcessLogonTransactionCommand(Guid transactionId,
Guid estateId,
Guid merchantId,
String imeiNumber,
String transactionType,
DateTime transactionDateTime,
String transactionNumber,
Guid commandId) : base(commandId)
{
this.TransactionId = transactionId;
this.EstateId = estateId;
this.IMEINumber = imeiNumber;
this.MerchantId = merchantId;
Expand Down Expand Up @@ -104,14 +108,15 @@ private ProcessLogonTransactionCommand(Guid estateId,
/// <param name="transactionDateTime">The transaction date time.</param>
/// <param name="transactionNumber">The transaction number.</param>
/// <returns></returns>
public static ProcessLogonTransactionCommand Create(Guid estateId,
public static ProcessLogonTransactionCommand Create(Guid transactionId,
Guid estateId,
Guid merchantId,
String imeiNumber,
String transactionType,
DateTime transactionDateTime,
String transactionNumber)
{
return new ProcessLogonTransactionCommand(estateId, merchantId, imeiNumber, transactionType, transactionDateTime, transactionNumber, Guid.NewGuid());
return new ProcessLogonTransactionCommand(transactionId, estateId, merchantId, imeiNumber, transactionType, transactionDateTime, transactionNumber, Guid.NewGuid());
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace TransactionProcessor.BusinessLogic.Services
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Models;
Expand All @@ -16,7 +17,8 @@ public interface ITransactionDomainService
/// </summary>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
Task<ProcessLogonTransactionResponse> ProcessLogonTransaction(CancellationToken cancellationToken);
Task<ProcessLogonTransactionResponse> ProcessLogonTransaction(Guid transactionId, Guid estateId, Guid merchantId, DateTime transactionDateTime,
String transactionNumber, String imeiNumber, CancellationToken cancellationToken);

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,64 @@
namespace TransactionProcessor.BusinessLogic.Services
{
using System;
using System.Threading;
using System.Threading.Tasks;
using Models;
using Shared.DomainDrivenDesign.EventStore;
using Shared.EventStore.EventStore;
using TransactionAggregate;

/// <summary>
///
/// </summary>
/// <seealso cref="TransactionProcessor.BusinessLogic.Services.ITransactionDomainService" />
public class TransactionDomainService : ITransactionDomainService
{
private readonly IAggregateRepositoryManager AggregateRepositoryManager;

public TransactionDomainService(IAggregateRepositoryManager aggregateRepositoryManager)
{
this.AggregateRepositoryManager = aggregateRepositoryManager;
}

#region Methods

/// <summary>
/// Processes the logon transaction.
/// </summary>
/// <param name="transactionId"></param>
/// <param name="estateId"></param>
/// <param name="merchantId"></param>
/// <param name="transactionDateTime"></param>
/// <param name="transactionNumber"></param>
/// <param name="imeiNumber"></param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns></returns>
public async Task<ProcessLogonTransactionResponse> ProcessLogonTransaction(CancellationToken cancellationToken)
public async Task<ProcessLogonTransactionResponse> ProcessLogonTransaction(Guid transactionId, Guid estateId, Guid merchantId, DateTime transactionDateTime,
String transactionNumber, String imeiNumber, CancellationToken cancellationToken)
{
IAggregateRepository<TransactionAggregate> transactionAggregateRepository = this.AggregateRepositoryManager.GetAggregateRepository<TransactionAggregate>(estateId);

TransactionAggregate transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken);
transactionAggregate.StartTransaction(transactionDateTime, transactionNumber, "Logon", estateId, merchantId, imeiNumber);
await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken);

transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken);
transactionAggregate.AuthoriseTransactionLocally("ABCD1234", "0000", "SUCCESS");
await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken);

transactionAggregate = await transactionAggregateRepository.GetLatestVersion(transactionId, cancellationToken);
transactionAggregate.CompleteTransaction();
await transactionAggregateRepository.SaveChanges(transactionAggregate, cancellationToken);

return new ProcessLogonTransactionResponse
{
ResponseMessage = "SUCCESS",
ResponseCode = 0
ResponseMessage = transactionAggregate.ResponseMessage,
ResponseCode = transactionAggregate.ResponseCode
};
}


#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<ItemGroup>
<PackageReference Include="Shared" Version="0.0.4.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="0.0.4.1" />
<PackageReference Include="Shared.EventStore" Version="0.0.4.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -15,6 +16,7 @@

<ItemGroup>
<ProjectReference Include="..\TransactionProcessor.Models\TransactionProcessor.Models.csproj" />
<ProjectReference Include="..\TransactionProcessor.TransactionAgrgegate\TransactionProcessor.TransactionAggregate.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LogonTransactionResponse
/// <value>
/// The response code.
/// </value>
public Int32 ResponseCode { get; set; }
public String ResponseCode { get; set; }

/// <summary>
/// Gets or sets the response message.
Expand Down
10 changes: 10 additions & 0 deletions TransactionProcessor.IntegrationTests/Common/DockerHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TransactionProcessor.IntegrationTests.Common
{
class DockerHelper
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ClientProxyBase" Version="0.0.4.1" />
<PackageReference Include="Ductus.FluentDocker" Version="2.7.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<PackageReference Include="SpecFlow" Version="3.1.44-beta" />
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.1.44-beta" />
<PackageReference Include="SpecFlow.xUnit" Version="3.1.44-beta" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.1.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class ProcessLogonTransactionResponse
/// <value>
/// The response code.
/// </value>
public Int32 ResponseCode { get; set; }
public String ResponseCode { get; set; }

/// <summary>
/// Gets or sets the response message.
Expand Down
Loading