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
6 changes: 6 additions & 0 deletions .github/workflows/createrelease.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ jobs:

- name: Build Code
run: dotnet build TransactionProcessor.sln --configuration Release

- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"

- name: Build Docker Images
run: |
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,11 @@ jobs:
- name: Build Code
run: dotnet build TransactionProcessor.sln --configuration Release

- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"

- name: Build Docker Image
run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest
6 changes: 6 additions & 0 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ jobs:
- name: Build Code
run: dotnet build TransactionProcessor.sln --configuration Release

- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "TransactionProcessor.BusinessLogic.Tests\TransactionProcessor.BusinessLogic.Tests.csproj"
dotnet test "TransactionProcessor.Tests\TransactionProcessor.Tests.csproj"

- name: Build Docker Image
run: docker build . --file TransactionProcessor/Dockerfile --tag transactionprocessor:latest

Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TransactionProcessor.BusinessLogic.Tests.CommandHandler
{
using System.Threading;
using System.Threading.Tasks;
using BusinessLogic.Commands;
using CommandHandlers;
using Commands;
using Moq;
using Services;
using Shared.DomainDrivenDesign.CommandHandling;
using Shouldly;
using Testing;
using Xunit;

public class CommandRouterTests
{
[Fact]
public void CommandRouter_ProcessLogonTransactionCommand_IsRouted()
{
Mock<ITransactionDomainService> transactionDomainService = new Mock<ITransactionDomainService>();
ICommandRouter router = new CommandRouter(transactionDomainService.Object);

ProcessLogonTransactionCommand command = TestData.ProcessLogonTransactionCommand;

Should.NotThrow(async () =>
{
await router.Route(command, CancellationToken.None);
});
}
}

public class TransactionDomainServiceTests
{
[Fact(Skip = "Complete once aggregate in place")]
public async Task TransactionDomainService_ProcessLogonTransaction_LogonTransactionIsProcesses()
{
//Mock<IAggregateRepository<EstateAggregate>> estateAggregateRepository = new Mock<IAggregateRepository<EstateAggregate>>();
//estateAggregateRepository.Setup(m => m.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(new EstateAggregate());
//estateAggregateRepository.Setup(m => m.SaveChanges(It.IsAny<EstateAggregate>(), It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);

//Mock<IAggregateRepositoryManager> aggregateRepositoryManager = new Mock<IAggregateRepositoryManager>();
//aggregateRepositoryManager.Setup(x => x.GetAggregateRepository<EstateAggregate>(It.IsAny<Guid>())).Returns(estateAggregateRepository.Object);

//EstateDomainService domainService = new EstateDomainService(aggregateRepositoryManager.Object);

//Should.NotThrow(async () =>
//{
// await domainService.CreateEstate(TestData.EstateId,
// TestData.EstateName,
// CancellationToken.None);
//});
throw new NotImplementedException();
}
}
}


Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace TransactionProcessor.BusinessLogic.Tests.CommandHandler
{
using System.Threading;
using BusinessLogic.Commands;
using CommandHandlers;
using Commands;
using Moq;
using Services;
using Shared.DomainDrivenDesign.CommandHandling;
using Shouldly;
using Testing;
using Xunit;

public class TransactionCommandHandlerTests
{
[Fact]
public void EstateCommandHandler_CreateEstateCommand_IsHandled()
{
Mock<ITransactionDomainService> transactionDomainService = new Mock<ITransactionDomainService>();
ICommandHandler handler = new TransactionCommandHandler(transactionDomainService.Object);

ProcessLogonTransactionCommand command = TestData.ProcessLogonTransactionCommand;

Should.NotThrow(async () =>
{
await handler.Handle(command, CancellationToken.None);
});

}
}
}
30 changes: 30 additions & 0 deletions TransactionProcessor.BusinessLogic.Tests/Commands/CommandTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace TransactionProcessor.BusinessLogic.Tests.Commands
{
using BusinessLogic.Commands;
using Shouldly;
using Testing;
using Xunit;

public class CommandTests
{
[Fact]
public void ProcessLogonTransactionCommand_CanBeCreated_IsCreated()
{
ProcessLogonTransactionCommand processLogonTransactionCommand = ProcessLogonTransactionCommand.Create(TestData.EstateId, TestData.MerchantId, TestData.IMEINumber,TestData.TransactionType, TestData.TransactionDateTime,
TestData.TransactionNumber);

processLogonTransactionCommand.ShouldNotBeNull();
processLogonTransactionCommand.CommandId.ShouldNotBe(Guid.Empty);
processLogonTransactionCommand.EstateId.ShouldBe(TestData.EstateId);
processLogonTransactionCommand.MerchantId.ShouldBe(TestData.MerchantId);
processLogonTransactionCommand.IMEINumber.ShouldBe(TestData.IMEINumber);
processLogonTransactionCommand.TransactionType.ShouldBe(TestData.TransactionType);
processLogonTransactionCommand.TransactionDateTime.ShouldBe(TestData.TransactionDateTime);
processLogonTransactionCommand.TransactionNumber.ShouldBe(TestData.TransactionNumber);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<DebugType>None</DebugType>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="Moq" Version="4.13.1" />
<PackageReference Include="Shouldly" Version="3.0.2" />
<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.msbuild" Version="2.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

</ItemGroup>

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

<ItemGroup>
<ProjectReference Include="..\TransactionProcessor.BusinessLogic\TransactionProcessor.BusinessLogic.csproj" />
<ProjectReference Include="..\TransactionProcessor.Testing\TransactionProcessor.Testing.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,105 @@ public class ProcessLogonTransactionCommand : Command<ProcessLogonTransactionRes
#region Constructors

/// <summary>
/// Initializes a new instance of the <see cref="ProcessLogonTransactionCommand"/> class.
/// Initializes a new instance of the <see cref="ProcessLogonTransactionCommand" /> class.
/// </summary>
/// <param name="estateId">The estate identifier.</param>
/// <param name="merchantId">The merchant identifier.</param>
/// <param name="imeiNumber">The imei number.</param>
/// <param name="transactionType">Type of the transaction.</param>
/// <param name="transactionDateTime">The transaction date time.</param>
/// <param name="transactionNumber">The transaction number.</param>
/// <param name="commandId">The command identifier.</param>
public ProcessLogonTransactionCommand(Guid commandId) : base(commandId)
private ProcessLogonTransactionCommand(Guid estateId,
Guid merchantId,
String imeiNumber,
String transactionType,
DateTime transactionDateTime,
String transactionNumber,
Guid commandId) : base(commandId)
{
this.EstateId = estateId;
this.IMEINumber = imeiNumber;
this.MerchantId = merchantId;
this.TransactionDateTime = transactionDateTime;
this.TransactionNumber = transactionNumber;
this.TransactionType = transactionType;
}

#endregion

#region Properties

/// <summary>
/// Gets the estate identifier.
/// </summary>
/// <value>
/// The estate identifier.
/// </value>
public Guid EstateId { get; }

/// <summary>
/// Gets the imei number.
/// </summary>
/// <value>
/// The imei number.
/// </value>
public String IMEINumber { get; }

/// <summary>
/// Gets the merchant identifier.
/// </summary>
/// <value>
/// The merchant identifier.
/// </value>
public Guid MerchantId { get; }

/// <summary>
/// Gets the transaction date time.
/// </summary>
/// <value>
/// The transaction date time.
/// </value>
public DateTime TransactionDateTime { get; }

/// <summary>
/// Gets the transaction number.
/// </summary>
/// <value>
/// The transaction number.
/// </value>
public String TransactionNumber { get; }

/// <summary>
/// Gets the type of the transaction.
/// </summary>
/// <value>
/// The type of the transaction.
/// </value>
public String TransactionType { get; }

#endregion

#region Methods

/// <summary>
/// Creates the specified estate identifier.
/// </summary>
/// <param name="estateId">The estate identifier.</param>
/// <param name="merchantId">The merchant identifier.</param>
/// <param name="imeiNumber">The imei number.</param>
/// <param name="transactionType">Type of the transaction.</param>
/// <param name="transactionDateTime">The transaction date time.</param>
/// <param name="transactionNumber">The transaction number.</param>
/// <returns></returns>
public static ProcessLogonTransactionCommand Create(Guid estateId,
Guid merchantId,
String imeiNumber,
String transactionType,
DateTime transactionDateTime,
String transactionNumber)
{
return new ProcessLogonTransactionCommand(estateId, merchantId, imeiNumber, transactionType, transactionDateTime, transactionNumber, Guid.NewGuid());
}

#endregion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace TransactionProcessor.DataTransferObjects
{
using System;
using System.Diagnostics.CodeAnalysis;

/// <summary>
///
/// </summary>
[ExcludeFromCodeCoverage]
public class LogonTransactionRequest
{
#region Properties
Expand All @@ -25,6 +27,14 @@ public class LogonTransactionRequest
/// </value>
public Guid MerchantId { get; set; }

/// <summary>
/// Gets or sets the estate identifier.
/// </summary>
/// <value>
/// The estate identifier.
/// </value>
public Guid EstateId { get; set; }

/// <summary>
/// Gets or sets the transaction date time.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace TransactionProcessor.DataTransferObjects
{
using System;
using System.Diagnostics.CodeAnalysis;

/// <summary>
///
/// </summary>
[ExcludeFromCodeCoverage]
public class LogonTransactionResponse
{
#region Properties
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace TransactionProcessor.Models
{
using System;
using System.Diagnostics.CodeAnalysis;

/// <summary>
///
/// </summary>
[ExcludeFromCodeCoverage]
public class ProcessLogonTransactionResponse
{
#region Properties
Expand Down
Loading