예제 #1
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)));
        }
예제 #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_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)));
        }
예제 #4
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)));
        }