public static async Task PublishClanInvitationSentIntegrationEventAsync(this IServiceBusPublisher publisher, UserId userId, Clan clan) { var integrationEvent = new ClanInvitationSentIntegrationEvent { UserId = userId, Clan = new ClanDto { Id = clan.Id, Name = clan.Name, Summary = clan.Summary, OwnerId = clan.OwnerId } }; await publisher.PublishAsync(integrationEvent); }
public async Task HandleAsync_WhenClanInvitationSentIntegrationEventIsValid_ShouldBeCompletedTask() { // Arrange var userId = new UserId(); var clanId = new ClanId(); TestMock.UserService.Setup(userService => userService.SendEmailAsync(It.IsAny <UserId>(), It.IsAny <string>(), It.IsAny <object>())) .Returns(Task.CompletedTask) .Verifiable(); var handler = new ClanInvitationSentIntegrationEventHandler(TestMock.UserService.Object, TestMock.SendgridOptions.Object); var integrationEvent = new ClanInvitationSentIntegrationEvent { Clan = new ClanDto { Id = clanId, Name = "testClan", OwnerId = userId, Summary = "", Members = { new MemberDto { ClanId = clanId, Id = new MemberId(), UserId = userId } } } }; // Act await handler.HandleAsync(integrationEvent); // Assert TestMock.UserService.Verify(userService => userService.SendEmailAsync(It.IsAny <UserId>(), It.IsAny <string>(), It.IsAny <object>()), Times.Once); }