Skip to content

Commit b5996c1

Browse files
fix failing test
1 parent 836d900 commit b5996c1

File tree

35 files changed

+128
-117
lines changed

35 files changed

+128
-117
lines changed

TransactionProcessor.BusinessLogic.Tests/DomainEventHandlers/TransactionDomainEventHandlerTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ public TransactionDomainEventHandlerTests()
7676
}
7777

7878
[Theory]
79-
[InlineData(SettlementSchedule.Immediate)]
80-
[InlineData(SettlementSchedule.Weekly)]
81-
[InlineData(SettlementSchedule.Monthly)]
82-
public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_SuccessfulSale_EventIsHandled(SettlementSchedule settlementSchedule)
79+
[InlineData(EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate)]
80+
[InlineData(EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly)]
81+
[InlineData(EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly)]
82+
public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenCompletedEvent_SuccessfulSale_EventIsHandled(EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule settlementSchedule)
8383
{
8484
this.FloatAggregateRepository.Setup(f => f.GetLatestVersion(It.IsAny<Guid>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.GetFloatAggregateWithCostValues);
8585

@@ -94,7 +94,7 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
9494
});
9595

9696
this.EstateClient.Setup(e => e.GetMerchant(It.IsAny<String>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
97-
.ReturnsAsync(new MerchantResponse
97+
.ReturnsAsync(new EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse
9898
{
9999
SettlementSchedule = settlementSchedule,
100100
});
@@ -111,16 +111,16 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
111111

112112
CalculatedFee merchantFee = transactionAggregate.GetFees().SingleOrDefault(f => f.FeeId == TestData.TransactionFeeId);
113113
merchantFee.ShouldNotBeNull();
114-
if (settlementSchedule == SettlementSchedule.Immediate){
114+
if (settlementSchedule == EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate){
115115
merchantFee.IsSettled.ShouldBeTrue();
116116
}
117117
else{
118118
merchantFee.IsSettled.ShouldBeFalse();
119119
}
120120

121121
var expectedSettlementDate = settlementSchedule switch{
122-
SettlementSchedule.Monthly => transactionAggregate.TransactionDateTime.Date.AddMonths(1),
123-
SettlementSchedule.Weekly => transactionAggregate.TransactionDateTime.Date.AddDays(7),
122+
EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly => transactionAggregate.TransactionDateTime.Date.AddMonths(1),
123+
EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly => transactionAggregate.TransactionDateTime.Date.AddDays(7),
124124
_ => transactionAggregate.TransactionDateTime.Date
125125
};
126126
merchantFee.SettlementDueDate.ShouldBe(expectedSettlementDate);
@@ -145,9 +145,9 @@ public async Task TransactionDomainEventHandler_Handle_TransactionHasBeenComplet
145145
});
146146

147147
this.EstateClient.Setup(e => e.GetMerchant(It.IsAny<String>(), It.IsAny<Guid>(), It.IsAny<Guid>(), It.IsAny<CancellationToken>()))
148-
.ReturnsAsync(new MerchantResponse
148+
.ReturnsAsync(new EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse
149149
{
150-
SettlementSchedule = SettlementSchedule.NotSet,
150+
SettlementSchedule = EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.NotSet,
151151
});
152152
this.EstateClient.Setup(e => e.GetTransactionFeesForProduct(It.IsAny<String>(),
153153
It.IsAny<Guid>(),

TransactionProcessor.BusinessLogic.Tests/Services/FloatDomainServiceTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace TransactionProcessor.BusinessLogic.Tests.Services
99
using System.Threading;
1010
using EstateManagement.Client;
1111
using EstateManagement.DataTransferObjects.Responses;
12+
using EstateManagement.DataTransferObjects.Responses.Contract;
1213
using FloatAggregate;
1314
using Microsoft.Extensions.Configuration;
1415
using Models;

TransactionProcessor.BusinessLogic.Tests/Services/TransactionDomainServiceTests.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
using BusinessLogic.Services;
88
using EstateManagement.Client;
99
using EstateManagement.DataTransferObjects.Requests;
10-
using EstateManagement.DataTransferObjects.Responses;
10+
using EstateManagement.DataTransferObjects.Requests.Merchant;
11+
using EstateManagement.DataTransferObjects.Responses.Merchant;
1112
using FloatAggregate;
1213
using Microsoft.Extensions.Configuration;
1314
using Models;
@@ -22,6 +23,7 @@
2223
using Testing;
2324
using TransactionAggregate;
2425
using Xunit;
26+
using MerchantResponse = EstateManagement.DataTransferObjects.Responses.MerchantResponse;
2527

2628
public class TransactionDomainServiceTests{
2729
#region Fields
@@ -82,11 +84,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_DeviceNeedsAd
8284
It.IsAny<Guid>(),
8385
It.IsAny<AddMerchantDeviceRequest>(),
8486
It.IsAny<CancellationToken>()))
85-
.ReturnsAsync(new AddMerchantDeviceResponse{
86-
DeviceId = TestData.DeviceId,
87-
MerchantId = TestData.MerchantId,
88-
EstateId = TestData.TransactionId,
89-
});
87+
.Returns(Task.CompletedTask);
9088

9189
this.SecurityServiceClient.Setup(s => s.GetToken(It.IsAny<String>(), It.IsAny<String>(), It.IsAny<CancellationToken>())).ReturnsAsync(TestData.TokenResponse);
9290

@@ -242,7 +240,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_DeclinedByOper
242240
this.OperatorProxy.Setup(o => o.ProcessSaleMessage(It.IsAny<String>(),
243241
It.IsAny<Guid>(),
244242
It.IsAny<Guid>(),
245-
It.IsAny<MerchantResponse>(),
243+
It.IsAny<EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse>(),
246244
It.IsAny<DateTime>(),
247245
It.IsAny<String>(),
248246
It.IsAny<Dictionary<String, String>>(),
@@ -301,7 +299,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_ExceptionInOpe
301299
this.OperatorProxy.Setup(o => o.ProcessSaleMessage(It.IsAny<String>(),
302300
It.IsAny<Guid>(),
303301
It.IsAny<Guid>(),
304-
It.IsAny<MerchantResponse>(),
302+
It.IsAny<EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse>(),
305303
It.IsAny<DateTime>(),
306304
It.IsAny<String>(),
307305
It.IsAny<Dictionary<String, String>>(),
@@ -400,7 +398,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_TransactionIsP
400398
this.OperatorProxy.Setup(o => o.ProcessSaleMessage(It.IsAny<String>(),
401399
It.IsAny<Guid>(),
402400
It.IsAny<Guid>(),
403-
It.IsAny<MerchantResponse>(),
401+
It.IsAny<EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse>(),
404402
It.IsAny<DateTime>(),
405403
It.IsAny<String>(),
406404
It.IsAny<Dictionary<String, String>>(),
@@ -468,7 +466,7 @@ public async Task TransactionDomainService_ProcessSaleTransaction_NoFloatFound_T
468466
this.OperatorProxy.Setup(o => o.ProcessSaleMessage(It.IsAny<String>(),
469467
It.IsAny<Guid>(),
470468
It.IsAny<Guid>(),
471-
It.IsAny<MerchantResponse>(),
469+
It.IsAny<EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse>(),
472470
It.IsAny<DateTime>(),
473471
It.IsAny<String>(),
474472
It.IsAny<Dictionary<String, String>>(),

TransactionProcessor.BusinessLogic.Tests/Services/TransactionReceiptBuilderTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public async Task TransactionReceiptBuilder_GetEmailReceiptMessage_MessageBuilt(
3737

3838
TransactionReceiptBuilder receiptBuilder = new TransactionReceiptBuilder(fileSystem);
3939

40-
String receiptMessage = await receiptBuilder.GetEmailReceiptMessage(transaction, new MerchantResponse(),"OperatorName", CancellationToken.None);
40+
String receiptMessage = await receiptBuilder.GetEmailReceiptMessage(transaction, new EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse(),"OperatorName", CancellationToken.None);
4141

4242
receiptMessage.ShouldBe("Transaction Number: 12345");
4343

TransactionProcessor.BusinessLogic/EventHandling/TransactionDomainEventHandler.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using EstateManagement.Database.Entities;
1212
using EstateManagement.DataTransferObjects;
1313
using EstateManagement.DataTransferObjects.Responses;
14+
using EstateManagement.DataTransferObjects.Responses.Estate;
1415
using FloatAggregate;
1516
using Manager;
1617
using MessagingService.Client;
@@ -29,8 +30,10 @@
2930
using Transaction.DomainEvents;
3031
using TransactionAggregate;
3132
using CalculationType = Models.CalculationType;
32-
using ContractProductTransactionFee = EstateManagement.DataTransferObjects.Responses.ContractProductTransactionFee;
33+
using ContractProductTransactionFee = EstateManagement.DataTransferObjects.Responses.Contract.ContractProductTransactionFee;
3334
using FeeType = Models.FeeType;
35+
using MerchantResponse = EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse;
36+
using Transaction = Models.Transaction;
3437

3538
/// <summary>
3639
///
@@ -108,13 +111,13 @@ public async Task Handle(IDomainEvent domainEvent,
108111
await this.HandleSpecificDomainEvent((dynamic)domainEvent, cancellationToken);
109112
}
110113

111-
private DateTime CalculateSettlementDate(SettlementSchedule merchantSettlementSchedule,
114+
private DateTime CalculateSettlementDate(EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule merchantSettlementSchedule,
112115
DateTime completeDateTime) {
113-
if (merchantSettlementSchedule == SettlementSchedule.Weekly) {
116+
if (merchantSettlementSchedule == EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Weekly) {
114117
return completeDateTime.Date.AddDays(7).Date;
115118
}
116119

117-
if (merchantSettlementSchedule == SettlementSchedule.Monthly) {
120+
if (merchantSettlementSchedule == EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Monthly) {
118121
return completeDateTime.Date.AddMonths(1).Date;
119122
}
120123

@@ -188,10 +191,10 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do
188191
List<CalculatedFee> merchantFees = resultFees.Where(f => f.FeeType == FeeType.Merchant).ToList();
189192

190193
if (merchantFees.Any()){
191-
MerchantResponse merchant =
194+
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant =
192195
await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, domainEvent.EstateId, domainEvent.MerchantId, cancellationToken);
193196

194-
if (merchant.SettlementSchedule == SettlementSchedule.NotSet){
197+
if (merchant.SettlementSchedule == EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.NotSet){
195198
throw new NotSupportedException($"Merchant {merchant.MerchantId} does not have a settlement schedule configured");
196199
}
197200

@@ -202,7 +205,7 @@ private async Task HandleSpecificDomainEvent(TransactionHasBeenCompletedEvent do
202205
transactionAggregate.AddFeePendingSettlement(calculatedFee, settlementDate);
203206

204207

205-
if (merchant.SettlementSchedule == SettlementSchedule.Immediate){
208+
if (merchant.SettlementSchedule == EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate){
206209
Guid settlementId = Helpers.CalculateSettlementAggregateId(settlementDate, domainEvent.MerchantId, domainEvent.EstateId);
207210

208211
// Add fees to transaction now if settlement is immediate
@@ -248,13 +251,13 @@ private async Task HandleSpecificDomainEvent(SettledMerchantFeeAddedToTransactio
248251
CancellationToken cancellationToken){
249252
Guid aggregateId = Helpers.CalculateSettlementAggregateId(domainEvent.SettledDateTime.Date, domainEvent.MerchantId, domainEvent.EstateId);
250253

251-
MerchantResponse merchant = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, domainEvent.EstateId, domainEvent.MerchantId, cancellationToken);
254+
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant = await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, domainEvent.EstateId, domainEvent.MerchantId, cancellationToken);
252255

253256
// We need to add the fees to a pending settlement stream
254257
SettlementAggregate aggregate = await this.SettlementAggregateRepository.GetLatestVersion(aggregateId, cancellationToken);
255258

256259

257-
if (merchant.SettlementSchedule == SettlementSchedule.Immediate){
260+
if (merchant.SettlementSchedule == EstateManagement.DataTransferObjects.Responses.Merchant.SettlementSchedule.Immediate){
258261
aggregate.ImmediatelyMarkFeeAsSettled(domainEvent.MerchantId, domainEvent.TransactionId, domainEvent.FeeId);
259262
}
260263
else {
@@ -320,13 +323,13 @@ private async Task HandleSpecificDomainEvent(CustomerEmailReceiptRequestedEvent
320323

321324
TransactionAggregate transactionAggregate =
322325
await this.TransactionAggregateRepository.GetLatestVersion(domainEvent.TransactionId, cancellationToken);
323-
var transaction = transactionAggregate.GetTransaction();
326+
Transaction transaction = transactionAggregate.GetTransaction();
324327

325328
MerchantResponse merchant =
326329
await this.EstateClient.GetMerchant(this.TokenResponse.AccessToken, domainEvent.EstateId, domainEvent.MerchantId, cancellationToken);
327330

328-
var estate = await this.EstateClient.GetEstate(this.TokenResponse.AccessToken, domainEvent.EstateId, cancellationToken);
329-
var @operator = estate.Operators.Single(o => o.OperatorId == transaction.OperatorId);
331+
EstateResponse estate = await this.EstateClient.GetEstate(this.TokenResponse.AccessToken, domainEvent.EstateId, cancellationToken);
332+
EstateOperatorResponse @operator = estate.Operators.Single(o => o.OperatorId == transaction.OperatorId);
330333

331334
// Determine the body of the email
332335
String receiptMessage = await this.TransactionReceiptBuilder.GetEmailReceiptMessage(transactionAggregate.GetTransaction(), merchant, @operator.Name, cancellationToken);

TransactionProcessor.BusinessLogic/OperatorInterfaces/IOperatorProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Task<OperatorResponse> ProcessLogonMessage(String accessToken,
1818
Task<OperatorResponse> ProcessSaleMessage(String accessToken,
1919
Guid transactionId,
2020
Guid operatorId,
21-
MerchantResponse merchant,
21+
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant,
2222
DateTime transactionDateTime,
2323
String transactionReference,
2424
Dictionary<String, String> additionalTransactionMetadata,

TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPostPay/PataPawaPostPayProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private void PostEvictionCallback(Object key,
9191
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken,
9292
Guid transactionId,
9393
Guid operatorId,
94-
MerchantResponse merchant,
94+
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant,
9595
DateTime transactionDateTime,
9696
String transactionReference,
9797
Dictionary<String, String> additionalTransactionMetadata,

TransactionProcessor.BusinessLogic/OperatorInterfaces/PataPawaPrePay/PataPawaPrePayProxy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ public async Task<OperatorResponse> ProcessLogonMessage(String accessToken, Canc
5555
return this.CreateFromLogon(responseContent);
5656
}
5757

58-
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken, Guid transactionId, Guid operatorId, MerchantResponse merchant, DateTime transactionDateTime, String transactionReference, Dictionary<String, String> additionalTransactionMetadata, CancellationToken cancellationToken){
58+
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken, Guid transactionId, Guid operatorId,
59+
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant, DateTime transactionDateTime, String transactionReference, Dictionary<String, String> additionalTransactionMetadata, CancellationToken cancellationToken){
5960
// Get the logon response for the operator
6061
OperatorResponse logonResponse = this.MemoryCache.Get<OperatorResponse>("PataPawaPrePayLogon");
6162
if (logonResponse == null)

TransactionProcessor.BusinessLogic/OperatorInterfaces/SafaricomPinless/SafaricomPinlessProxy.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public async Task<OperatorResponse> ProcessLogonMessage(String accessToken,
7474
public async Task<OperatorResponse> ProcessSaleMessage(String accessToken,
7575
Guid transactionId,
7676
Guid operatorId,
77-
MerchantResponse merchant,
77+
EstateManagement.DataTransferObjects.Responses.Merchant.MerchantResponse merchant,
7878
DateTime transactionDateTime,
7979
String transactionReference,
8080
Dictionary<String, String> additionalTransactionMetadata,

0 commit comments

Comments
 (0)