コード例 #1
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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public void ValidateMaxAge_ParticipanteForaDaIdade_test()
        {
            //Setup
            _personRepository = new Mock <IExamplePersonRepository>();

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

            var person = new ExamplePerson()
            {
                Name      = "Usuario 1",
                BirthDate = DateTime.Today.AddYears(-(ExamplesConstants.MAX_AGE + 1))
            };

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

            //Assert
            Assert.Equal(_examplesMessages.GetIdadeNaoPermitida(), ex.Message);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public void ValidateAvancedAge_ParticipanteDentroDaIdadeWarningDate_test()
        {
            //Setup
            _personRepository = new Mock <IExamplePersonRepository>();

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

            var person = new ExamplePerson()
            {
                Id        = 1,
                Name      = "Usuario 1",
                BirthDate = DateTime.Today.AddYears(-(ExamplesConstants.WARNING_MAX_AGE + 1))
            };

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

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

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