示例#1
0
        public void Validar_Sucesso_test()
        {
            //Setup
            var person = GenerateEntity.GenerateExamplePerson(null
                                                              , null
                                                              , null
                                                              , null);

            //Fact
            app.Validar(person);

            //Assert
        }
示例#2
0
        public void Validar_NomeMuitoGrande_Ex_test()
        {
            //Setup
            var person = GenerateEntity.GenerateExamplePerson(null
                                                              , "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901"
                                                              , null
                                                              , null);
            //Fact
            ValidationException ex = Assert.Throws <ValidationException>(() => app.Validar(person));

            //Assert
            Assert.Equal("GetMaxLenght", ex.Erros[0]);
        }
示例#3
0
        public void Validar_NomeNaoPreenchido_Ex_test()
        {
            //Setup
            var person = GenerateEntity.GenerateExamplePerson(null
                                                              , ""
                                                              , null
                                                              , null);
            //Fact
            ValidationException ex = Assert.Throws <ValidationException>(() => app.Validar(person));

            //Assert
            Assert.Equal("GetNameRequired", ex.Erros[0]);
        }
        public void ValidateAvancedAge_ParticipanteDentroDaIdade_Success_test()
        {
            //Setup
            _personRepository = new Mock <IExamplePersonRepository>();

            var app = new ExamplePersonBusiness(_personRepository.Object, _examplesMessages.Object, _examplesConstants.Object);

            var person = GenerateEntity.GenerateExamplePerson(null
                                                              , null
                                                              , DateTime.Today.AddYears(-(_examplesConstants.Object.GetWarningMaxAge() - 1))
                                                              , null);

            _personRepository.Setup(x => x.Create(It.IsAny <ExamplePerson>())).Returns(person);

            //Fact
            app.SavePerson(person);
        }
        public void ValidateMaxAge_ParticipanteForaDaIdade_Ex_test()
        {
            //Setup
            _personRepository = new Mock <IExamplePersonRepository>();

            var app = new ExamplePersonBusiness(_personRepository.Object, _examplesMessages.Object, _examplesConstants.Object);

            var person = GenerateEntity.GenerateExamplePerson(null
                                                              , null
                                                              , DateTime.Today.AddYears(-(_examplesConstants.Object.GetMaxAge() + 1))
                                                              , null);

            //Fact
            BusinessException ex = Assert.Throws <BusinessException>(() => app.SavePerson(person));

            //Assert
            Assert.Equal(_examplesMessages.Object.GetIdadeNaoPermitida(), ex.Message);
        }
        public void ValidateAvancedAge_ParticipanteDentroDaIdadeMasWarningDate_Ex_test()
        {
            //Setup
            _personRepository = new Mock <IExamplePersonRepository>();

            var app = new ExamplePersonBusiness(_personRepository.Object, _examplesMessages.Object, _examplesConstants.Object);

            var person = GenerateEntity.GenerateExamplePerson(null
                                                              , null
                                                              , DateTime.Today.AddYears(-(_examplesConstants.Object.GetWarningMaxAge() + 1))
                                                              , null);

            _personRepository.Setup(x => x.Create(It.IsAny <ExamplePerson>())).Returns(person);

            //Fact
            BusinessException ex = Assert.Throws <BusinessException>(() => app.SavePerson(person));

            //Assert
            Assert.Equal(_examplesMessages.Object.GetIdadeAvancada(), ex.Message);
        }