@@ -358,21 +358,10 @@ public async Task HandlePullLegalEntity_WithSharingStateError_ThrowsServiceExcep
358358 public async Task HandlePullLegalEntity_WithSharingProcessStartedNotSet_ReturnsExpected ( )
359359 {
360360 // Arrange
361- var company = new Company ( Guid . NewGuid ( ) , "Test Company" , CompanyStatusId . ACTIVE , DateTimeOffset . UtcNow )
362- {
363- BusinessPartnerNumber = "1"
364- } ;
361+ var context = PreparePullLegalEntity ( ) ;
365362 var checklistEntry = _fixture . Build < ApplicationChecklistEntry > ( )
366363 . With ( x => x . ApplicationChecklistEntryStatusId , ApplicationChecklistEntryStatusId . TO_DO )
367364 . Create ( ) ;
368- var checklist = new Dictionary < ApplicationChecklistEntryTypeId , ApplicationChecklistEntryStatusId >
369- {
370- { ApplicationChecklistEntryTypeId . REGISTRATION_VERIFICATION , ApplicationChecklistEntryStatusId . DONE } ,
371- { ApplicationChecklistEntryTypeId . BUSINESS_PARTNER_NUMBER , ApplicationChecklistEntryStatusId . TO_DO }
372- }
373- . ToImmutableDictionary ( ) ;
374- var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithoutSharingProcessStarted , default , checklist , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
375- SetupForHandlePullLegalEntity ( company ) ;
376365
377366 // Act
378367 var result = await _logic . HandlePullLegalEntity ( context , CancellationToken . None ) ;
@@ -386,6 +375,78 @@ public async Task HandlePullLegalEntity_WithSharingProcessStartedNotSet_ReturnsE
386375 result . ProcessMessage . Should ( ) . Be ( "SharingProcessStarted was not set" ) ;
387376 }
388377
378+ [ Fact ]
379+ public async Task HandlePullLegalEntity_BringYourOwnWallet_True_ReturnsExpected ( )
380+ {
381+ // Arrange
382+ var context = PreparePullLegalEntity ( ) ;
383+
384+ A . CallTo ( ( ) => _bpdmService . GetSharingState ( A < Guid > . _ , A < CancellationToken > . _ ) )
385+ . Returns ( Task . FromResult ( new BpdmSharingState (
386+ Guid . NewGuid ( ) ,
387+ BpdmSharingStateType . Success ,
388+ null ,
389+ null ,
390+ DateTimeOffset . UtcNow ,
391+ null
392+ ) ) ) ;
393+ var bpdmLegalEntityOutputData = _fixture . Build < BpdmLegalEntityOutputData > ( )
394+ . With ( x => x . LegalEntity ,
395+ new BpdmLegelEntityData ( "CAXSDUMMYCATENAZZ" ,
396+ null ,
397+ null ,
398+ null ,
399+ _fixture . Create < BpdmConfidenceCriteria > ( ) , Enumerable . Empty < BpdmStatus > ( ) )
400+ ) . Create ( ) ;
401+
402+ A . CallTo ( ( ) => _bpdmService . FetchInputLegalEntity ( context . ApplicationId . ToString ( ) , A < CancellationToken > . _ ) )
403+ . Returns ( bpdmLegalEntityOutputData ) ;
404+
405+ A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( true ) ;
406+
407+ // Act
408+ var result = await _logic . HandlePullLegalEntity ( context , CancellationToken . None ) ;
409+
410+ // Assert
411+ result . ScheduleStepTypeIds . Should ( ) . ContainSingle ( x => x == ProcessStepTypeId . TRANSMIT_BPN_DID ) ;
412+ }
413+
414+ [ Fact ]
415+ public async Task HandlePullLegalEntity_BringYourOwnWallet_False_ReturnsExpected ( )
416+ {
417+ // Arrange
418+ var context = PreparePullLegalEntity ( ) ;
419+
420+ A . CallTo ( ( ) => _bpdmService . GetSharingState ( A < Guid > . _ , A < CancellationToken > . _ ) )
421+ . Returns ( Task . FromResult ( new BpdmSharingState (
422+ Guid . NewGuid ( ) ,
423+ BpdmSharingStateType . Success ,
424+ null ,
425+ null ,
426+ DateTimeOffset . UtcNow ,
427+ null
428+ ) ) ) ;
429+ var bpdmLegalEntityOutputData = _fixture . Build < BpdmLegalEntityOutputData > ( )
430+ . With ( x => x . LegalEntity ,
431+ new BpdmLegelEntityData ( "CAXSDUMMYCATENAZZ" ,
432+ null ,
433+ null ,
434+ null ,
435+ _fixture . Create < BpdmConfidenceCriteria > ( ) , Enumerable . Empty < BpdmStatus > ( ) )
436+ ) . Create ( ) ;
437+
438+ A . CallTo ( ( ) => _bpdmService . FetchInputLegalEntity ( context . ApplicationId . ToString ( ) , A < CancellationToken > . _ ) )
439+ . Returns ( bpdmLegalEntityOutputData ) ;
440+
441+ A . CallTo ( ( ) => _companyRepository . IsBringYourOwnWallet ( A < Guid > . _ ) ) . Returns ( false ) ;
442+
443+ // Act
444+ var result = await _logic . HandlePullLegalEntity ( context , CancellationToken . None ) ;
445+
446+ // Assert
447+ result . ScheduleStepTypeIds . Should ( ) . ContainSingle ( x => x == ProcessStepTypeId . CREATE_IDENTITY_WALLET ) ;
448+ }
449+
389450 [ Fact ]
390451 public async Task HandlePullLegalEntity_WithSharingTypePending_ReturnsExpected ( )
391452 {
@@ -576,4 +637,24 @@ private void SetupForHandlePullLegalEntity(Company? company = null)
576637 }
577638
578639 #endregion
640+
641+ private IApplicationChecklistService . WorkerChecklistProcessStepData PreparePullLegalEntity ( )
642+ {
643+ var company = new Company ( Guid . NewGuid ( ) , "Test Company" , CompanyStatusId . ACTIVE , DateTimeOffset . UtcNow )
644+ {
645+ BusinessPartnerNumber = "1"
646+ } ;
647+ var checklistEntry = _fixture . Build < ApplicationChecklistEntry > ( )
648+ . With ( x => x . ApplicationChecklistEntryStatusId , ApplicationChecklistEntryStatusId . TO_DO )
649+ . Create ( ) ;
650+ var checklist = new Dictionary < ApplicationChecklistEntryTypeId , ApplicationChecklistEntryStatusId >
651+ {
652+ { ApplicationChecklistEntryTypeId . REGISTRATION_VERIFICATION , ApplicationChecklistEntryStatusId . DONE } ,
653+ { ApplicationChecklistEntryTypeId . BUSINESS_PARTNER_NUMBER , ApplicationChecklistEntryStatusId . TO_DO }
654+ }
655+ . ToImmutableDictionary ( ) ;
656+ var context = new IApplicationChecklistService . WorkerChecklistProcessStepData ( IdWithoutSharingProcessStarted , default , checklist , Enumerable . Empty < ProcessStepTypeId > ( ) ) ;
657+ SetupForHandlePullLegalEntity ( company ) ;
658+ return context ;
659+ }
579660}
0 commit comments