public async Task PasswordRegister_ShouldReturnBadRequestWhenUnsuccessful() { var userManager = GetMockedUserManager(); var emailService = new Mock <IEmailTemplatesClient>().Object; userManager.Setup(u => u.CreateAsync(It.IsAny <IdentityUser>(), It.IsAny <string>())) .ReturnsAsync(IdentityResult.Failed()); var controller = new RegistrationController(emailService) { UserManager = userManager.Object }; var result = await controller.PasswordRegister(new PasswordRegisterModel()); Assert.AreSame(typeof(BadRequestResult), result.GetType()); }
public async Task PasswordRegister_ShouldReturnSuccessResponseWhenSuccessful() { var userManager = GetMockedUserManager(); var url = new Mock <UrlHelper>().Object; var emailService = new Mock <IEmailTemplatesClient>().Object; userManager.Setup(u => u.CreateAsync(It.IsAny <IdentityUser>(), It.IsAny <string>())) .ReturnsAsync(IdentityResult.Success); userManager.Setup(u => u.FindByNameAsync(It.IsAny <string>())).ReturnsAsync(new IdentityUser(string.Empty)); var controller = new RegistrationController(emailService) { UserManager = userManager.Object, Url = url }; var result = await controller.PasswordRegister(new PasswordRegisterModel()); Assert.AreSame(typeof(OkResult), result.GetType()); }