コード例 #1
0
 public static UsuarioEntity Create(UsuarioBaseCommand command)
 {
     return(new UsuarioEntity
            (
                command.Id,
                command.Nome,
                command.Sobrenome,
                new Email(command.Email),
                new DataNascimento(command.DataNascimento),
                (Perfil)command.Perfil
            ));
 }
コード例 #2
0
        public void DeveSer_Invalido_Quando_Email_Nao_Informado()
        {
            var command = new UsuarioBaseCommand
            {
                Nome           = "Alexandre",
                Sobrenome      = "Del Picolo",
                DataNascimento = DateTime.Now.AddYears(-1),
                Perfil         = (int)Perfil.Administrador
            };

            var modelState = new UsuarioBaseCommandValidator().Validate(command);

            Assert.IsTrue(modelState.Errors.Any(x => x.PropertyName == nameof(command.Email)));
        }
コード例 #3
0
        public void DeveSer_Invalido_Quando_DataNascimento_Nao_Informada()
        {
            var command = new UsuarioBaseCommand
            {
                Nome      = "Alexandre",
                Sobrenome = "Del Picolo",
                Email     = "*****@*****.**",
                Perfil    = (int)Perfil.Administrador
            };

            var modelState = new UsuarioBaseCommandValidator().Validate(command);

            Assert.IsTrue(modelState.Errors.Any(x => x.PropertyName == nameof(command.DataNascimento)));
        }
コード例 #4
0
        public void DeveSer_Invalido_Quando_Nome_Menor_Que_Tres_Caracteres()
        {
            var command = new UsuarioBaseCommand
            {
                Nome           = "12",
                Sobrenome      = "Del Picolo",
                Email          = "*****@*****.**",
                DataNascimento = DateTime.Now.AddYears(-1),
                Perfil         = (int)Perfil.Administrador
            };

            var modelState = new UsuarioBaseCommandValidator().Validate(command);

            Assert.IsTrue(modelState.Errors.Any(x => x.PropertyName == nameof(command.Nome)));
        }
コード例 #5
0
        public void DeveSer_Invalido_Quando_Perfil_Nao_Existe()
        {
            var command = new UsuarioBaseCommand
            {
                Nome           = "Alexandre",
                Sobrenome      = "Del Picolo",
                Email          = "*****@*****.**",
                DataNascimento = DateTime.Now.AddYears(-1),
                Perfil         = 99
            };

            var modelState = new UsuarioBaseCommandValidator().Validate(command);

            Assert.IsTrue(modelState.Errors.Any(x => x.PropertyName == nameof(command.Perfil)));
        }
コード例 #6
0
 public static UsuarioDomain Criar(UsuarioBaseCommand command)
 {
     return(new UsuarioDomain(new NomeCompleto(command.Nome, command.SobreNome), command.DataNascimento, command.Status));
 }
コード例 #7
0
 private static UsuarioDomain UpdateBase(UsuarioBaseCommand command, int Id)
 {
     return(new UsuarioDomain(Id, new NomeCompleto(command.Nome, command.SobreNome), command.DataNascimento, command.Status));
 }