コード例 #1
0
        public static async Task Run([NServiceBusTrigger(EndPoint = QueueNames.AccountUpdated)] ChangedAccountNameEvent message, [Inject] IAccountNameUpdatedHandler handler, [Inject] ILogger <ChangedAccountNameEvent> log)
        {
            log.LogInformation($"NServiceBus AccountCreated trigger function executed at: {DateTime.Now} for ${message.AccountId}:${message.CurrentName}");
            await handler.Handle(message);

            log.LogInformation($"NServiceBus AccountCreated trigger function finished at: {DateTime.Now} for ${message.AccountId}:${message.CurrentName}");
        }
コード例 #2
0
        public async Task Then_The_Service_Is_Called_To_Update_The_Entity(
            ChangedAccountNameEvent changedAccountNameEvent,
            [Frozen] Mock <IAccountsService> service,
            AccountNameUpdatedHandler handler)
        {
            //Act
            await handler.Handle(changedAccountNameEvent);

            //Assert
            service.Verify(x => x.UpdateAccountName(changedAccountNameEvent.AccountId, changedAccountNameEvent.CurrentName));
        }
        public async Task Then_The_Message_Will_Be_Handled()
        {
            //Arrange
            var handler = new Mock <IAccountNameUpdatedHandler>();
            var message = new ChangedAccountNameEvent {
                AccountId = 1, CurrentName = "Test"
            };

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

            //Assert
            handler.Verify(x => x.Handle(
                               It.Is <ChangedAccountNameEvent>(c => c.AccountId.Equals(message.AccountId) &&
                                                               c.CurrentName.Equals(message.CurrentName))));
        }
 public async Task Handle(ChangedAccountNameEvent accountNameChangeEvent)
 {
     await _accountsService.UpdateAccountName(accountNameChangeEvent.AccountId,
                                              accountNameChangeEvent.CurrentName);
 }