44 using System . Threading ;
55 using System . Threading . Tasks ;
66 using BusinessLogic . Services ;
7+ using EstateManagement . Client ;
78 using Microsoft . Extensions . Configuration ;
89 using Models ;
910 using Moq ;
11+ using SecurityService . Client ;
1012 using SettlementAggregates ;
1113 using Shared . DomainDrivenDesign . EventSourcing ;
1214 using Shared . EventStore . Aggregate ;
@@ -23,16 +25,23 @@ public class SettlementDomainServiceTests
2325
2426 private Mock < IAggregateRepository < SettlementAggregate , DomainEvent > > settlementAggregateRepository ;
2527
28+ private Mock < ISecurityServiceClient > securityServiceClient ;
29+
30+ private Mock < IEstateClient > estateClient ;
31+
2632 private SettlementDomainService settlementDomainService ;
2733
2834 public SettlementDomainServiceTests ( ) {
2935 this . transactionAggregateRepository =
3036 new Mock < IAggregateRepository < TransactionAggregate , DomainEvent > > ( ) ;
3137 this . settlementAggregateRepository =
3238 new Mock < IAggregateRepository < SettlementAggregate , DomainEvent > > ( ) ;
39+ this . securityServiceClient = new Mock < ISecurityServiceClient > ( ) ;
40+ this . estateClient = new Mock < IEstateClient > ( ) ;
3341
3442 this . settlementDomainService =
35- new SettlementDomainService ( this . transactionAggregateRepository . Object , settlementAggregateRepository . Object ) ;
43+ new SettlementDomainService ( this . transactionAggregateRepository . Object , settlementAggregateRepository . Object ,
44+ this . securityServiceClient . Object , this . estateClient . Object ) ;
3645
3746 IConfigurationRoot configurationRoot = new ConfigurationBuilder ( ) . AddInMemoryCollection ( TestData . DefaultAppSettings ) . Build ( ) ;
3847 ConfigurationReader . Initialise ( configurationRoot ) ;
@@ -48,6 +57,11 @@ public async Task SettlementDomainService_ProcessSettlement_SettlementIsProcesse
4857 this . transactionAggregateRepository . Setup ( s => s . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
4958 . ReturnsAsync ( TestData . GetCompletedAuthorisedSaleTransactionAggregate ) ;
5059
60+ this . securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
61+
62+ this . estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
63+ . ReturnsAsync ( TestData . GetMerchantResponseWithOperator1 ) ;
64+
5165 ProcessSettlementResponse response = await settlementDomainService . ProcessSettlement ( TestData . SettlementDate ,
5266 TestData . EstateId ,
5367 TestData . MerchantId ,
@@ -82,6 +96,11 @@ public async Task SettlementDomainService_ProcessSettlement_SettlementAggregateN
8296 settlementAggregateRepository . Setup ( s => s . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
8397 . ReturnsAsync ( TestData . GetCreatedSettlementAggregate ) ;
8498
99+ this . securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
100+
101+ this . estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
102+ . ReturnsAsync ( TestData . GetMerchantResponseWithOperator1 ) ;
103+
85104 ProcessSettlementResponse response = await settlementDomainService . ProcessSettlement ( TestData . SettlementDate ,
86105 TestData . EstateId ,
87106 TestData . MerchantId ,
@@ -99,6 +118,11 @@ public async Task SettlementDomainService_ProcessSettlement_AddSettledFeeThrownE
99118 settlementAggregateRepository . Setup ( s => s . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
100119 . ReturnsAsync ( TestData . GetSettlementAggregateWithPendingMerchantFees ( 10 ) ) ;
101120
121+ this . securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
122+
123+ this . estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
124+ . ReturnsAsync ( TestData . GetMerchantResponseWithOperator1 ) ;
125+
102126 ProcessSettlementResponse response = await settlementDomainService . ProcessSettlement ( TestData . SettlementDate ,
103127 TestData . EstateId ,
104128 TestData . MerchantId ,
@@ -110,4 +134,4 @@ public async Task SettlementDomainService_ProcessSettlement_AddSettledFeeThrownE
110134 response . NumberOfFeesSuccessfullySettled . ShouldBe ( 0 ) ;
111135 }
112136 }
113- }
137+ }
0 commit comments