示例#1
0
        public async Task HandleAsync_WhenUserGameCredentialRemovedIntegrationEventIsValid_ShouldBeCompletedTask()
        {
            // Arrange
            var userId     = new UserId();
            var user       = new User();
            var mockLogger = new MockLogger <UserGameCredentialRemovedIntegrationEventHandler>();

            TestMock.UserService.Setup(userService => userService.FindByIdAsync(It.IsAny <string>())).ReturnsAsync(user).Verifiable();

            TestMock.UserService.Setup(userService => userService.RemoveClaimAsync(It.IsAny <User>(), It.IsAny <Claim>()))
            .ReturnsAsync(new IdentityResult())
            .Verifiable();

            var handler = new UserGameCredentialRemovedIntegrationEventHandler(TestMock.UserService.Object, mockLogger.Object);

            var integrationEvent = new UserGameCredentialRemovedIntegrationEvent

            {
                Credential = new GameCredentialDto
                {
                    Game     = EnumGame.LeagueOfLegends,
                    PlayerId = new PlayerId(),
                    UserId   = userId
                }
            };

            // Act
            await handler.HandleAsync(integrationEvent);

            // Assert
            TestMock.UserService.Verify(userService => userService.FindByIdAsync(It.IsAny <string>()), Times.Once);
            TestMock.UserService.Verify(userService => userService.RemoveClaimAsync(It.IsAny <User>(), It.IsAny <Claim>()), Times.Once);
            mockLogger.Verify(Times.Once());
        }
示例#2
0
        public async Task HandleAsync_WhenUserGameCredentialRemovedIntegrationEventIsValid_ShouldBeCompletedTask()
        {
            // Arrange
            TestMock.UserService.Setup(userService => userService.SendEmailAsync(It.IsAny <UserId>(), It.IsAny <string>(), It.IsAny <object>()))
            .Returns(Task.CompletedTask)
            .Verifiable();

            var handler = new UserGameCredentialRemovedIntegrationEventHandler(TestMock.UserService.Object, TestMock.SendgridOptions.Object);

            var integrationEvent = new UserGameCredentialRemovedIntegrationEvent
            {
                Credential = new GameCredentialDto
                {
                    Game     = EnumGame.LeagueOfLegends,
                    PlayerId = new PlayerId(),
                    UserId   = new UserId()
                }
            };

            // Act
            await handler.HandleAsync(integrationEvent);

            // Assert
            TestMock.UserService.Verify(userService => userService.SendEmailAsync(It.IsAny <UserId>(), It.IsAny <string>(), It.IsAny <object>()), Times.Once);
        }