public async Task CreateWhenUserNotCompleteShouldReturnOperationResultFailed(SystemUserCreateViewModel systemUserCreateViewModel) { SystemUserManager systemUserManager = new SystemUserManager(systemUserRepository, mapper, encrypService, emailService); IOperationResult <bool> actual = await systemUserManager.Create(systemUserCreateViewModel); Assert.IsFalse(actual.Success); Assert.AreEqual("Todos los campos son requeridos", actual.Message); }
public async Task <IActionResult> Create(SystemUserCreateViewModel systemUserToCreate) { IOperationResult <bool> createResult = await _systemUserManager.Create(systemUserToCreate); if (!createResult.Success) { return(BadRequest(createResult.Message)); } return(Ok()); }
public async Task CreateWhenEncrypTextThrowShouldReturnOperationResultFailed() { encrypService.EncrypText(Arg.Any <string>()).Throws(new Exception()); SystemUserManager systemUserManager = new SystemUserManager(systemUserRepository, mapper, encrypService, emailService); IOperationResult <bool> actual = await systemUserManager.Create(systemUserCreateViewModel); Assert.IsFalse(actual.Success); Assert.AreEqual("Ha ocurrido un error creando el usuario", actual.Message); }
public async Task CreateWhenAllSuccessShouldReturnOperationResultSuccess() { SystemUser systemUser = new SystemUser { Email = "uncorreovacano" }; encrypService.EncrypText(Arg.Any <string>()).Returns("texto encriptado"); mapper.Map <SystemUser>(Arg.Any <SystemUserCreateViewModel>()).Returns(systemUser); SystemUserManager systemUserManager = new SystemUserManager(systemUserRepository, mapper, encrypService, emailService); IOperationResult <bool> actual = await systemUserManager.Create(systemUserCreateViewModel); Assert.IsTrue(actual.Success); }
public async Task CreateWhenEmailServiceSendEmailThrowShouldReturnOperationResultFailed() { SystemUser systemUser = new SystemUser { Email = "uncorreovacano" }; encrypService.EncrypText(Arg.Any <string>()).Returns("texto encriptado"); mapper.Map <SystemUser>(Arg.Any <SystemUserCreateViewModel>()).Returns(systemUser); emailService.SendActivationEmail(Arg.Any <SystemUserActivationRequest>()).Throws(new Exception()); SystemUserManager systemUserManager = new SystemUserManager(systemUserRepository, mapper, encrypService, emailService); IOperationResult <bool> actual = await systemUserManager.Create(systemUserCreateViewModel); Assert.IsFalse(actual.Success); Assert.AreEqual("Ha ocurrido un error creando el usuario", actual.Message); }