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 )); }
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))); }
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))); }
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))); }
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))); }
public static UsuarioDomain Criar(UsuarioBaseCommand command) { return(new UsuarioDomain(new NomeCompleto(command.Nome, command.SobreNome), command.DataNascimento, command.Status)); }
private static UsuarioDomain UpdateBase(UsuarioBaseCommand command, int Id) { return(new UsuarioDomain(Id, new NomeCompleto(command.Nome, command.SobreNome), command.DataNascimento, command.Status)); }