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
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3" />
<PackageReference Include="Shared.EventStore" Version="2026.5.5" />
<PackageReference Include="Shared.EventStore" Version="2026.5.6" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.16.0" />
<PackageReference Include="Microsoft.IdentityModel.JsonWebTokens" Version="8.16.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ private EstateManagementContext GetContext(String databaseName)
}

public VoucherDomainEventHandlerTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
IConfigurationRoot configurationRoot = new ConfigurationBuilder().AddInMemoryCollection(TestData.DefaultAppSettings).Build();
ConfigurationReader.Initialise(configurationRoot);
Logger.Initialise(NullLogger.Instance);
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));


SecurityServiceClient = new Mock<ISecurityServiceClient>();
MessagingServiceClient = new Mock<IMessagingServiceClient>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Moq;
using Shared.DomainDrivenDesign.EventSourcing;
using Shared.EventStore.Aggregate;
Expand All @@ -8,7 +9,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using TransactionProcessor.Aggregates;
using TransactionProcessor.BusinessLogic.Manager;
using TransactionProcessor.BusinessLogic.Services;
Expand All @@ -25,6 +25,8 @@ namespace TransactionProcessor.BusinessLogic.Tests.Manager
using ProjectionEngine.Database.Database;
using ProjectionEngine.Database.Database.Entities;
using Shared.EntityFramework;
using Shared.Serialisation;
using System.Text.Json;
using Testing;

public class VoucherManagementManagerTests
Expand All @@ -36,6 +38,7 @@ private EstateManagementContext GetContext(String databaseName) {
}

public VoucherManagementManagerTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
this.AggregateService = new Mock<IAggregateService>();
this.DbContextFactory = new Mock<IDbContextResolver<EstateManagementContext>>();
this.Context = this.GetContext(Guid.NewGuid().ToString("N"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using EventStore.Client;
using KurrentDB.Client;
using Newtonsoft.Json;
using KurrentDB.Client;
using Shared.Serialisation;
using SimpleResults;
using TransactionProcessor.BusinessLogic.Requests;
using TransactionProcessor.ProjectionEngine.Models;
Expand Down Expand Up @@ -101,8 +100,8 @@ public async Task<Result<String>> GetPartitionResultFromProjection(String projec
public async Task<Result<String>> GetPartitionStateFromProjection(String projectionName,
String partitionId,
CancellationToken cancellationToken) {
MerchantBalanceProjectionState1 state = new MerchantBalanceProjectionState1(new Merchant("", "", 0, 0, new Deposits(0, 0, DateTime.MinValue), new Withdrawals(0, 0, DateTime.MinValue), new AuthorisedSales(0, 0, DateTime.MinValue), new DeclinedSales(0, 0, DateTime.MinValue), new Fees(0, 0)) { });
return Result.Success<String>(JsonConvert.SerializeObject(state));
MerchantBalanceProjectionState1 state = new MerchantBalanceProjectionState1(new Merchant("", "", 0, 0));
return Result.Success<String>(StringSerialiser.Serialise(state));
}

public async Task<Result<String>> GetResultFromProjection(String projectionName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using System;
using SimpleResults;
using System;
using System.Threading.Tasks;
using SimpleResults;

namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces
{
using System.Threading;
using Common;
using Microsoft.Extensions.Caching.Memory;
using Moq;
using PataPawaPostPay;
using Shared.Serialisation;
using Shouldly;
using System.Text.Json;
using System.Threading;
using Testing;
using TransactionProcessor.BusinessLogic.OperatorInterfaces.PataPawaPostPay;
using Xunit;
Expand All @@ -26,6 +28,7 @@ public class PataPawaPostPayProxyTests{
private readonly IMemoryCache MemoryCache;

public PataPawaPostPayProxyTests(){
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
PataPawaPostPayService = new Mock<IPataPawaPostPayService>();
PataPawaPostPayServiceClient = new Mock<PataPawaPostPayServiceClient>();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using System;
using Microsoft.Extensions.Caching.Memory;
using RichardSzalay.MockHttp;
using Shared.Logger;
using Shared.Serialisation;
using Shouldly;
using SimpleResults;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Caching.Memory;
using Newtonsoft.Json;
using RichardSzalay.MockHttp;
using Shared.Logger;
using Shouldly;
using SimpleResults;
using TransactionProcessor.BusinessLogic.OperatorInterfaces;
using TransactionProcessor.BusinessLogic.OperatorInterfaces.PataPawaPrePay;
using TransactionProcessor.Testing;
Expand All @@ -23,6 +24,7 @@ public class PataPawaPrePayProxyTests {
private readonly IMemoryCache MemoryCache = new MemoryCache(new MemoryCacheOptions());

public PataPawaPrePayProxyTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
PataPawaPrePaidConfiguration configuration = new PataPawaPrePaidConfiguration();
configuration.Url = "http://localhost";
configuration.Password = "password";
Expand All @@ -41,7 +43,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_MessageProcessed() {

LogonResponse logonResponse = new LogonResponse { Balance = "0", Key = "Key", Msg = "Success", Status = 0 };

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(logonResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(logonResponse));

var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None);
result.IsSuccess.ShouldBeTrue();
Expand All @@ -66,7 +68,7 @@ public async Task PataPawaPrePayProxy_ProcessLogonMessage_FailedLogon_MessagePro
{
LogonResponse logonResponse = new LogonResponse { Balance = "0", Key = "Key", Msg = "Success", Status = -1 };

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(logonResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(logonResponse));

var result = await this.PataPawaPrePayProxy.ProcessLogonMessage(CancellationToken.None);
result.IsFailed.ShouldBeTrue();
Expand Down Expand Up @@ -102,7 +104,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Messag

MeterResponse meterResponse = new MeterResponse { Status = 0, Code = "1", CustomerName = "Customer", Msg = "msg" };

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(meterResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(meterResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down Expand Up @@ -132,7 +134,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_MeterTransaction_Failed

MeterResponse meterResponse = new MeterResponse { Status = -1, Code = "1", CustomerName = "Customer", Msg = "msg" };

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(meterResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(meterResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down Expand Up @@ -165,7 +167,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Message
CustomerName = "Mr Customer"
}};

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down Expand Up @@ -205,7 +207,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_FailedA
}
};

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down Expand Up @@ -245,7 +247,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_Custome
}
};

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down Expand Up @@ -285,7 +287,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_VendTransaction_AmountI
}
};

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down Expand Up @@ -323,7 +325,7 @@ public async Task PataPawaPrePayProxy_ProcessSaleMessage_UnknownMessageType_Mess
}
};

this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", JsonConvert.SerializeObject(vendResponse));
this.MockHttpMessageHandler.When("http://localhost").Respond("application/json", StringSerialiser.Serialise(vendResponse));

var result = await this.PataPawaPrePayProxy.ProcessSaleMessage(TestData.TransactionId,
TestData.OperatorId, TestData.Merchant, TestData.TransactionDateTime, TestData.TransactionReference,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
using System;
using SimpleResults;
using System;
using System.Collections.Generic;
using SimpleResults;

namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces
{
using System.Net;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using BusinessLogic.OperatorInterfaces;
using BusinessLogic.OperatorInterfaces.SafaricomPinless;
using Moq;
using Moq.Protected;
using Shared.Logger;
using Shared.Serialisation;
using Shouldly;
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Testing;
using Xunit;

public class SafaricomPinlessProxyTests
{
public SafaricomPinlessProxyTests(){
Logger.Initialise(NullLogger.Instance);
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@

namespace TransactionProcessor.BusinessLogic.Tests.OperatorInterfaces
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using BusinessLogic.OperatorInterfaces;
using BusinessLogic.OperatorInterfaces.VoucherManagement;
using MediatR;
using Moq;
using Requests;
using Shared.Serialisation;
using Shouldly;
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Testing;
using Xunit;

public class VoucherManagementProxyTests
{
public VoucherManagementProxyTests() {
Logger.Initialise(new NullLogger());
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,25 @@
using System.Threading.Tasks;
using SimpleResults;
using SimpleResults;
using System.Threading.Tasks;

namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler;

using System.Threading;
using BusinessLogic.Services;
using Moq;
using RequestHandlers;
using Requests;
using Shared.Serialisation;
using Shouldly;
using System.Text.Json;
using System.Threading;
using Testing;
using Xunit;

public class FloatRequestHandlerTests
{
public FloatRequestHandlerTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
}

[Fact]
public async Task FloatRequestHandler_CreateFloatForContractProductRequest_IsHandled(){
Mock<IFloatDomainService> floatDomainService = new Mock<IFloatDomainService>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using System.Threading;
using System.Threading.Tasks;
using Moq;
using Moq;
using Shared.DomainDrivenDesign.EventSourcing;
using Shared.EventStore.Aggregate;
using Shared.Serialisation;
using Shouldly;
using SimpleResults;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using TransactionProcessor.Aggregates;
using TransactionProcessor.BusinessLogic.Manager;
using TransactionProcessor.BusinessLogic.RequestHandlers;
Expand All @@ -17,6 +19,10 @@ namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler;

public class SettlementRequestHandlerTests
{
public SettlementRequestHandlerTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
}

[Fact]
public async Task SettlementRequestHandler_ProcessSettlementRequest_IsHandled()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System.Threading;
using System.Threading.Tasks;
using Moq;
using Moq;
using Shared.Serialisation;
using Shouldly;
using SimpleResults;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using TransactionProcessor.BusinessLogic.RequestHandlers;
using TransactionProcessor.BusinessLogic.Requests;
using TransactionProcessor.BusinessLogic.Services;
Expand All @@ -13,6 +15,10 @@ namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler
{
public class TransactionRequestHandlerTests
{
public TransactionRequestHandlerTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
}

[Fact]
public async Task TransactionRequestHandler_ProcessLogonTransactionRequest_IsHandled()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Moq;
using Moq;
using Shouldly;
using System;
using System.Threading.Tasks;
using TransactionProcessor.BusinessLogic.Manager;
using TransactionProcessor.BusinessLogic.RequestHandlers;
using TransactionProcessor.BusinessLogic.Requests;
Expand All @@ -10,11 +10,17 @@

namespace TransactionProcessor.BusinessLogic.Tests.RequestHandler
{
using Shared.Serialisation;
using System.Text.Json;
using System.Threading;
using Testing;

public class VoucherManagementRequestHandlerTests
{
public VoucherManagementRequestHandlerTests() {
StringSerialiser.Initialise(new SystemTextJsonSerializer(new JsonSerializerOptions()));
}

[Fact]
public async Task VoucherManagementRequestHandler_IssueVoucherRequest_IsHandled()
{
Expand Down
Loading
Loading