@@ -47,6 +47,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_TransactionIs
4747 Mock < ISecurityServiceClient > securityServiceClient = new Mock < ISecurityServiceClient > ( ) ;
4848
4949 securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
50+ estateClient . Setup ( e => e . GetEstate ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetEstateResponse ) ;
5051 estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
5152 . ReturnsAsync ( TestData . GetMerchantResponse ) ;
5253
@@ -89,6 +90,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_MerchantWithN
8990 Mock < ISecurityServiceClient > securityServiceClient = new Mock < ISecurityServiceClient > ( ) ;
9091
9192 securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
93+ estateClient . Setup ( e => e . GetEstate ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetEstateResponse ) ;
9294 estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
9395 . ReturnsAsync ( TestData . GetMerchantResponseWithNullDevices ) ;
9496
@@ -131,6 +133,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_MerchantWithN
131133 Mock < ISecurityServiceClient > securityServiceClient = new Mock < ISecurityServiceClient > ( ) ;
132134
133135 securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
136+ estateClient . Setup ( e => e . GetEstate ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetEstateResponse ) ;
134137 estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
135138 . ReturnsAsync ( TestData . GetMerchantResponseWithNoDevices ) ;
136139
@@ -173,6 +176,7 @@ public async Task TransactionDomainService_ProcessLogonTransaction_IncorrectDevi
173176 Mock < ISecurityServiceClient > securityServiceClient = new Mock < ISecurityServiceClient > ( ) ;
174177
175178 securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
179+ estateClient . Setup ( e => e . GetEstate ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetEstateResponse ) ;
176180 estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
177181 . ReturnsAsync ( TestData . GetMerchantResponse ) ;
178182
@@ -192,7 +196,48 @@ public async Task TransactionDomainService_ProcessLogonTransaction_IncorrectDevi
192196 response . ResponseMessage . ShouldBe ( TestData . ResponseMessage ) ;
193197 }
194198
195- // Txn for a Different Device (Causes a Validation Exception)
199+ [ Fact ]
200+ public async Task TransactionDomainService_ProcessLogonTransaction_InvlaidEstate_TransactionIsProcessed ( )
201+ {
202+ IConfigurationRoot configurationRoot = new ConfigurationBuilder ( ) . AddInMemoryCollection ( TestData . DefaultAppSettings ) . Build ( ) ;
203+ ConfigurationReader . Initialise ( configurationRoot ) ;
204+
205+ Logger . Initialise ( NullLogger . Instance ) ;
206+
207+ Mock < IAggregateRepositoryManager > aggregateRepositoryManager = new Mock < IAggregateRepositoryManager > ( ) ;
208+ Mock < IAggregateRepository < TransactionAggregate > > transactionAggregateRepository = new Mock < IAggregateRepository < TransactionAggregate > > ( ) ;
209+
210+ aggregateRepositoryManager . Setup ( x => x . GetAggregateRepository < TransactionAggregate > ( It . IsAny < Guid > ( ) ) ) . Returns ( transactionAggregateRepository . Object ) ;
211+ transactionAggregateRepository . SetupSequence ( t => t . GetLatestVersion ( It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
212+ . ReturnsAsync ( TestData . GetEmptyTransactionAggregate )
213+ . ReturnsAsync ( TestData . GetStartedTransactionAggregate )
214+ . ReturnsAsync ( TestData . GetLocallyAuthorisedTransactionAggregate )
215+ . ReturnsAsync ( TestData . GetCompletedTransactionAggregate ) ;
216+ transactionAggregateRepository . Setup ( t => t . SaveChanges ( It . IsAny < TransactionAggregate > ( ) , It . IsAny < CancellationToken > ( ) ) ) . Returns ( Task . CompletedTask ) ;
217+
218+ Mock < IEstateClient > estateClient = new Mock < IEstateClient > ( ) ;
219+ Mock < ISecurityServiceClient > securityServiceClient = new Mock < ISecurityServiceClient > ( ) ;
220+
221+ securityServiceClient . Setup ( s => s . GetToken ( It . IsAny < String > ( ) , It . IsAny < String > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . TokenResponse ) ;
222+ estateClient . Setup ( e => e . GetEstate ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) ) . ReturnsAsync ( TestData . GetEmptyEstateResponse ) ;
223+ estateClient . Setup ( e => e . GetMerchant ( It . IsAny < String > ( ) , It . IsAny < Guid > ( ) , It . IsAny < Guid > ( ) , It . IsAny < CancellationToken > ( ) ) )
224+ . ReturnsAsync ( TestData . GetMerchantResponse ) ;
225+
226+ TransactionDomainService transactionDomainService =
227+ new TransactionDomainService ( aggregateRepositoryManager . Object , estateClient . Object , securityServiceClient . Object ) ;
228+
229+ ProcessLogonTransactionResponse response = await transactionDomainService . ProcessLogonTransaction ( TestData . TransactionId ,
230+ TestData . EstateId ,
231+ TestData . MerchantId ,
232+ TestData . TransactionDateTime ,
233+ TestData . TransactionNumber ,
234+ TestData . DeviceIdentifier1 ,
235+ CancellationToken . None ) ;
236+
237+ response . ShouldNotBeNull ( ) ;
238+ response . ResponseCode . ShouldBe ( TestData . ResponseCode ) ;
239+ response . ResponseMessage . ShouldBe ( TestData . ResponseMessage ) ;
240+ }
196241
197242 }
198243}
0 commit comments