예제 #1
0
        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);
        }
예제 #2
0
        public async Task <IActionResult> Create(SystemUserCreateViewModel systemUserToCreate)
        {
            IOperationResult <bool> createResult = await _systemUserManager.Create(systemUserToCreate);

            if (!createResult.Success)
            {
                return(BadRequest(createResult.Message));
            }

            return(Ok());
        }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }