Ejemplo n.º 1
0
        public void ThrowException_WhenUserNameOrEmailAlreadyTaken(string userName, string email)
        {
            var userManager = MockHelper.MockUserManager <AppUser>().Object;
            var command     = new CreateAppUserCommand()
            {
                UserName = userName, Email = email
            };
            var handler = new CreateAppUserCommand.CreateAppUserCommandHandler(userManager, _identityContext);

            Assert.ThrowsAsync <NotCreatedException>(() => handler.Handle(command, CancellationToken.None));
        }
Ejemplo n.º 2
0
        public void ReturnedUserIdValueNotNull(string userName, string email)
        {
            var mockMngr = MockHelper.MockUserManager <AppUser>();

            mockMngr.Setup(um => um.CreateAsync(It.IsAny <AppUser>(), It.IsAny <string>())).ReturnsAsync(IdentityResult.Success);
            var command = new CreateAppUserCommand()
            {
                UserName = userName, Email = email, Password = "******"
            };
            var handler = new CreateAppUserCommand.CreateAppUserCommandHandler(mockMngr.Object, _identityContext);

            var task = handler.Handle(command, CancellationToken.None);

            Assert.NotNull(task.Result);
        }