Skip to content

Commit a5a550e

Browse files
Merge pull request #6 from StuartFerguson/task/#3_logonmessage
Added flow for Logon Transaction
2 parents 69b162a + bcaf2c9 commit a5a550e

File tree

23 files changed

+737
-9
lines changed

23 files changed

+737
-9
lines changed

.github/workflows/createrelease.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ jobs:
2929

3030
- name: Build Code
3131
run: dotnet build TransactionProcessor.sln --configuration Release
32+
33+
- name: Run Unit Tests
34+
run: |
35+
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
36+
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
37+
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"
3238
3339
- name: Build Docker Images
3440
run: |

.github/workflows/nightlybuild.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,11 @@ jobs:
2626
- name: Build Code
2727
run: dotnet build TransactionProcessor.sln --configuration Release
2828

29+
- name: Run Unit Tests
30+
run: |
31+
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
32+
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
33+
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"
34+
2935
- name: Build Docker Image
3036
run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest

.github/workflows/pullrequest.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
- name: Build Code
2828
run: dotnet build TransactionProcessor.sln --configuration Release
2929

30+
- name: Run Unit Tests
31+
run: |
32+
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
33+
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
34+
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"
35+
3036
- name: Build Docker Image
3137
run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest
3238

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace TransactionProcessor.BusinessLogic.Tests.CommandHandler
6+
{
7+
using System.Threading;
8+
using System.Threading.Tasks;
9+
using BusinessLogic.Commands;
10+
using CommandHandlers;
11+
using Commands;
12+
using Moq;
13+
using Services;
14+
using Shared.DomainDrivenDesign.CommandHandling;
15+
using Shouldly;
16+
using Testing;
17+
using Xunit;
18+
19+
public class CommandRouterTests
20+
{
21+
[Fact]
22+
public void CommandRouter_ProcessLogonTransactionCommand_IsRouted()
23+
{
24+
Mock<ITransactionDomainService> transactionDomainService = new Mock<ITransactionDomainService>();
25+
ICommandRouter router = new CommandRouter(transactionDomainService.Object);
26+
27+
ProcessLogonTransactionCommand command = TestData.ProcessLogonTransactionCommand;
28+
29+
Should.NotThrow(async () =>
30+
{
31+
await router.Route(command, CancellationToken.None);
32+
});
33+
}
34+
}
35+
36+
public class TransactionDomainServiceTests
37+
{
38+
[Fact(Skip = "Complete once aggregate in place")]
39+
public async Task TransactionDomainService_ProcessLogonTransaction_LogonTransactionIsProcesses()
40+
{
41+
//Mock<IAggregateRepository<EstateAggregate>> estateAggregateRepository = new Mock<IAggregateRepository<EstateAggregate>>();
42+
//estateAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(new EstateAggregate());
43+
//estateAggregateRepository.Setup(m => m.SaveChanges(It.IsAny<EstateAggregate>(), It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);
44+
45+
//Mock<IAggregateRepositoryManager> aggregateRepositoryManager = new Mock<IAggregateRepositoryManager>();
46+
//aggregateRepositoryManager.Setup(x => x.GetAggregateRepository<EstateAggregate>(It.IsAny<Guid>())).Returns(estateAggregateRepository.Object);
47+
48+
//EstateDomainService domainService = new EstateDomainService(aggregateRepositoryManager.Object);
49+
50+
//Should.NotThrow(async () =>
51+
//{
52+
// await domainService.CreateEstate(TestData.EstateId,
53+
// TestData.EstateName,
54+
// CancellationToken.None);
55+
//});
56+
throw new NotImplementedException();
57+
}
58+
}
59+
}
60+
61+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
namespace TransactionProcessor.BusinessLogic.Tests.CommandHandler
2+
{
3+
using System.Threading;
4+
using BusinessLogic.Commands;
5+
using CommandHandlers;
6+
using Commands;
7+
using Moq;
8+
using Services;
9+
using Shared.DomainDrivenDesign.CommandHandling;
10+
using Shouldly;
11+
using Testing;
12+
using Xunit;
13+
14+
public class TransactionCommandHandlerTests
15+
{
16+
[Fact]
17+
public void EstateCommandHandler_CreateEstateCommand_IsHandled()
18+
{
19+
Mock<ITransactionDomainService> transactionDomainService = new Mock<ITransactionDomainService>();
20+
ICommandHandler handler = new TransactionCommandHandler(transactionDomainService.Object);
21+
22+
ProcessLogonTransactionCommand command = TestData.ProcessLogonTransactionCommand;
23+
24+
Should.NotThrow(async () =>
25+
{
26+
await handler.Handle(command, CancellationToken.None);
27+
});
28+
29+
}
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace TransactionProcessor.BusinessLogic.Tests.Commands
6+
{
7+
using BusinessLogic.Commands;
8+
using Shouldly;
9+
using Testing;
10+
using Xunit;
11+
12+
public class CommandTests
13+
{
14+
[Fact]
15+
public void ProcessLogonTransactionCommand_CanBeCreated_IsCreated()
16+
{
17+
ProcessLogonTransactionCommand processLogonTransactionCommand = ProcessLogonTransactionCommand.Create(TestData.EstateId, TestData.MerchantId, TestData.IMEINumber,TestData.TransactionType, TestData.TransactionDateTime,
18+
TestData.TransactionNumber);
19+
20+
processLogonTransactionCommand.ShouldNotBeNull();
21+
processLogonTransactionCommand.CommandId.ShouldNotBe(Guid.Empty);
22+
processLogonTransactionCommand.EstateId.ShouldBe(TestData.EstateId);
23+
processLogonTransactionCommand.MerchantId.ShouldBe(TestData.MerchantId);
24+
processLogonTransactionCommand.IMEINumber.ShouldBe(TestData.IMEINumber);
25+
processLogonTransactionCommand.TransactionType.ShouldBe(TestData.TransactionType);
26+
processLogonTransactionCommand.TransactionDateTime.ShouldBe(TestData.TransactionDateTime);
27+
processLogonTransactionCommand.TransactionNumber.ShouldBe(TestData.TransactionNumber);
28+
}
29+
}
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<DebugType>None</DebugType>
6+
<IsPackable>false</IsPackable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
11+
<PackageReference Include="Moq" Version="4.13.1" />
12+
<PackageReference Include="Shouldly" Version="3.0.2" />
13+
<PackageReference Include="xunit" Version="2.4.1" />
14+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
15+
<PrivateAssets>all</PrivateAssets>
16+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
17+
</PackageReference>
18+
<PackageReference Include="coverlet.msbuild" Version="2.7.0">
19+
<PrivateAssets>all</PrivateAssets>
20+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
21+
</PackageReference>
22+
23+
</ItemGroup>
24+
25+
<ItemGroup>
26+
<Folder Include="Manager\" />
27+
<Folder Include="Services\" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<ProjectReference Include="..\TransactionProcessor.BusinessLogic\TransactionProcessor.BusinessLogic.csproj" />
32+
<ProjectReference Include="..\TransactionProcessor.Testing\TransactionProcessor.Testing.csproj" />
33+
</ItemGroup>
34+
35+
</Project>

TransactionProcessor.BusinessLogic/Commands/ProcessLogonTransactionCommand.cs

Lines changed: 96 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,105 @@ public class ProcessLogonTransactionCommand : Command<ProcessLogonTransactionRes
1313
#region Constructors
1414

1515
/// <summary>
16-
/// Initializes a new instance of the <see cref="ProcessLogonTransactionCommand"/> class.
16+
/// Initializes a new instance of the <see cref="ProcessLogonTransactionCommand" /> class.
1717
/// </summary>
18+
/// <param name="estateId">The estate identifier.</param>
19+
/// <param name="merchantId">The merchant identifier.</param>
20+
/// <param name="imeiNumber">The imei number.</param>
21+
/// <param name="transactionType">Type of the transaction.</param>
22+
/// <param name="transactionDateTime">The transaction date time.</param>
23+
/// <param name="transactionNumber">The transaction number.</param>
1824
/// <param name="commandId">The command identifier.</param>
19-
public ProcessLogonTransactionCommand(Guid commandId) : base(commandId)
25+
private ProcessLogonTransactionCommand(Guid estateId,
26+
Guid merchantId,
27+
String imeiNumber,
28+
String transactionType,
29+
DateTime transactionDateTime,
30+
String transactionNumber,
31+
Guid commandId) : base(commandId)
2032
{
33+
this.EstateId = estateId;
34+
this.IMEINumber = imeiNumber;
35+
this.MerchantId = merchantId;
36+
this.TransactionDateTime = transactionDateTime;
37+
this.TransactionNumber = transactionNumber;
38+
this.TransactionType = transactionType;
39+
}
40+
41+
#endregion
42+
43+
#region Properties
44+
45+
/// <summary>
46+
/// Gets the estate identifier.
47+
/// </summary>
48+
/// <value>
49+
/// The estate identifier.
50+
/// </value>
51+
public Guid EstateId { get; }
52+
53+
/// <summary>
54+
/// Gets the imei number.
55+
/// </summary>
56+
/// <value>
57+
/// The imei number.
58+
/// </value>
59+
public String IMEINumber { get; }
60+
61+
/// <summary>
62+
/// Gets the merchant identifier.
63+
/// </summary>
64+
/// <value>
65+
/// The merchant identifier.
66+
/// </value>
67+
public Guid MerchantId { get; }
68+
69+
/// <summary>
70+
/// Gets the transaction date time.
71+
/// </summary>
72+
/// <value>
73+
/// The transaction date time.
74+
/// </value>
75+
public DateTime TransactionDateTime { get; }
76+
77+
/// <summary>
78+
/// Gets the transaction number.
79+
/// </summary>
80+
/// <value>
81+
/// The transaction number.
82+
/// </value>
83+
public String TransactionNumber { get; }
84+
85+
/// <summary>
86+
/// Gets the type of the transaction.
87+
/// </summary>
88+
/// <value>
89+
/// The type of the transaction.
90+
/// </value>
91+
public String TransactionType { get; }
92+
93+
#endregion
94+
95+
#region Methods
96+
97+
/// <summary>
98+
/// Creates the specified estate identifier.
99+
/// </summary>
100+
/// <param name="estateId">The estate identifier.</param>
101+
/// <param name="merchantId">The merchant identifier.</param>
102+
/// <param name="imeiNumber">The imei number.</param>
103+
/// <param name="transactionType">Type of the transaction.</param>
104+
/// <param name="transactionDateTime">The transaction date time.</param>
105+
/// <param name="transactionNumber">The transaction number.</param>
106+
/// <returns></returns>
107+
public static ProcessLogonTransactionCommand Create(Guid estateId,
108+
Guid merchantId,
109+
String imeiNumber,
110+
String transactionType,
111+
DateTime transactionDateTime,
112+
String transactionNumber)
113+
{
114+
return new ProcessLogonTransactionCommand(estateId, merchantId, imeiNumber, transactionType, transactionDateTime, transactionNumber, Guid.NewGuid());
21115
}
22116

23117
#endregion

TransactionProcessor.DataTransferObjects/LogonTransactionRequest.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace TransactionProcessor.DataTransferObjects
22
{
33
using System;
4+
using System.Diagnostics.CodeAnalysis;
45

56
/// <summary>
67
///
78
/// </summary>
9+
[ExcludeFromCodeCoverage]
810
public class LogonTransactionRequest
911
{
1012
#region Properties
@@ -25,6 +27,14 @@ public class LogonTransactionRequest
2527
/// </value>
2628
public Guid MerchantId { get; set; }
2729

30+
/// <summary>
31+
/// Gets or sets the estate identifier.
32+
/// </summary>
33+
/// <value>
34+
/// The estate identifier.
35+
/// </value>
36+
public Guid EstateId { get; set; }
37+
2838
/// <summary>
2939
/// Gets or sets the transaction date time.
3040
/// </summary>

TransactionProcessor.DataTransferObjects/LogonTransactionResponse.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
namespace TransactionProcessor.DataTransferObjects
22
{
33
using System;
4+
using System.Diagnostics.CodeAnalysis;
45

56
/// <summary>
67
///
78
/// </summary>
9+
[ExcludeFromCodeCoverage]
810
public class LogonTransactionResponse
911
{
1012
#region Properties

0 commit comments

Comments
 (0)