示例#1
0
        public static async Task Run([NServiceBusTrigger(EndPoint = QueueNames.SignedAgreement)] SignedAgreementEvent message, [Inject] ISignedLegalAgreementHandler handler, [Inject] ILogger <SignedAgreementEvent> log)
        {
            log.LogInformation($"NServiceBus HandleSignedAgreementEvent trigger function executed at: {DateTime.Now} for account:{message.AccountId}-legal entity id:{message.LegalEntityId} - {message.OrganisationName}");
            await handler.Handle(message);

            log.LogInformation($"NServiceBus HandleSignedAgreementEvent trigger function finished");
        }
示例#2
0
 private AccountLegalEntity MapAccountLegalEntity(SignedAgreementEvent signedAgreementEvent)
 {
     return(new AccountLegalEntity
     {
         AccountId = signedAgreementEvent.AccountId,
         LegalEntityId = signedAgreementEvent.LegalEntityId
     });
 }
        public Task RunEvent([NServiceBusTrigger(Endpoint = QueueNames.AgreementSigned)] SignedAgreementEvent message)
        {
            var signRequest = new SignAgreementRequest
            {
                AccountId            = message.AccountId,
                AccountLegalEntityId = message.AccountLegalEntityId,
                AgreementVersion     = message.SignedAgreementVersion
            };

            return(_agreementsService.SignAgreement(signRequest));
        }
 public async Task Handle(SignedAgreementEvent signedAgreementEvent)
 {
     try
     {
         await _service.SignAgreementForAccountLegalEntity(signedAgreementEvent);
     }
     catch (DbUpdateException e)
     {
         _logger.LogWarning("Could not update levy status to is levy payer", e);
         throw;
     }
 }
        public async Task Then_Queue_Message_Will_Be_Created()
        {
            //Arrange
            var handler = new Mock <ISignedLegalAgreementHandler>();
            var message = new SignedAgreementEvent {
                AccountId = 432
            };

            //Act
            await HandleSignedAgreementEvent.Run(message, handler.Object, Mock.Of <ILogger <SignedAgreementEvent> >());

            //Assert
            handler.Verify(s => s.Handle(It.Is <SignedAgreementEvent>(c => c.AccountId.Equals(message.AccountId))), Times.Once);
        }
        public void Then_Will_Not_Throw_Exception_If_Signing_Agreement_And_Database_Update_Fails()
        {
            //Arrange
            var signedAgreementEvent = new SignedAgreementEvent
            {
                AccountId     = 5,
                LegalEntityId = 56
            };

            _service.Setup(x => x.SignAgreementForAccountLegalEntity(It.IsAny <SignedAgreementEvent>()))
            .ThrowsAsync(new DbUpdateException("Failed", (Exception)null));

            //Act + Assert
            Assert.ThrowsAsync <DbUpdateException>(() => _handler.Handle(signedAgreementEvent));
        }
        public async Task Then_The_Service_Is_Called_To_Update_The_Entity()
        {
            //Arrange
            var signedAgreementEvent = new SignedAgreementEvent
            {
                AccountId     = 5,
                LegalEntityId = 56
            };

            //Act
            await _handler.Handle(signedAgreementEvent);

            //Assert
            _service.Verify(x => x.SignAgreementForAccountLegalEntity(It.Is <SignedAgreementEvent>(
                                                                          c => c.AccountId.Equals(signedAgreementEvent.AccountId) &&
                                                                          c.LegalEntityId.Equals(signedAgreementEvent.LegalEntityId))));
        }
        public async Task Then_The_Event_Is_Mapped_To_The_Entity_And_Update_Called_On_The_Repository()
        {
            //Arrange
            var signedAgreementEvent = new SignedAgreementEvent
            {
                AccountId     = 9786,
                LegalEntityId = 543
            };

            //Act
            await _service.SignAgreementForAccountLegalEntity(signedAgreementEvent);

            //Assert
            _repository.Verify(x => x.UpdateAgreementStatus(
                                   It.Is <AccountLegalEntity>(c => c.AccountId.Equals(signedAgreementEvent.AccountId) &&
                                                              c.LegalEntityId.Equals(signedAgreementEvent.LegalEntityId))));
        }
示例#9
0
        public SignedAgreementEventHandlerTestsFixture()
        {
            Message = new SignedAgreementEvent
            {
                AccountId              = AccountId,
                UserRef                = UserRef,
                Created                = Created,
                AgreementId            = AgreementId,
                LegalEntityId          = LegalEntityId,
                OrganisationName       = OrganisationName,
                UserName               = UserName,
                AgreementType          = AgreementType,
                CohortCreated          = CohortCreated,
                SignedAgreementVersion = SignedAgreementVersion
            };

            Mediator = new Mock <IMediator>();
            Handler  = new SignedAgreementEventHandler(Mediator.Object);
        }
        public async Task Handle_WhenHandlingAddedPayeSchemeEvent_ThenShouldSendSignedAgreementCommand(
            TestableMessageHandlerContext context,
            [Frozen] Mock <IMediator> mediator,
            SignedAgreementEventHandler handler,
            SignedAgreementEvent message)
        {
            //arrange

            //act
            await handler.Handle(message, context);

            //assert
            mediator.Verify(s => s.Send(It.Is <SignedAgreementCommand>(c =>
                                                                       c.AccountId == message.AccountId &&
                                                                       c.AgreementId == message.AgreementId &&
                                                                       c.LegalEntityId == message.LegalEntityId &&
                                                                       c.OrganisationName == message.OrganisationName &&
                                                                       c.UserName == message.UserName &&
                                                                       c.UserRef == message.UserRef &&
                                                                       c.CorrelationId == message.CorrelationId), It.IsAny <CancellationToken>()));
        }
示例#11
0
 public async Task SignAgreementForAccountLegalEntity(SignedAgreementEvent signedAgreementEvent)
 {
     await _repository.UpdateAgreementStatus(MapAccountLegalEntity(signedAgreementEvent));
 }