Esempio n. 1
0
        public void IsDateValid_LaterThanExpiration_ReturnFalse()
        {
            var idCard = new IdentityCard
            {
                Id = 1,
                NationalRegisterNumber = "654.23.45-456-78",
                BirthDate      = new DateTime(1994, 02, 24),
                CardNumber     = 1234567891,
                Firstname      = "John",
                Lastname       = "Doe",
                ValidityDate   = new DateTime(2016, 11, 18),
                ExpirationDate = new DateTime(2016, 11, 18)
            };

            var isDateValid = idCard.IsDateValid();

            Assert.False(isDateValid);
        }
Esempio n. 2
0
        private void ValidateIdCard(IdentityCard idCard)
        {
            if (!idCard.IsDateValid())
            {
                throw new CustomBadRequestException(ExceptionMessage.IdCardInvalidDate);
            }

            if (DateTime.Compare(idCard.ExpirationDate, DateTime.Today) < 0)
            {
                throw new CustomBadRequestException(ExceptionMessage.IdCardExpired);
            }

            if (!IdentityCard.IsValidNiss(idCard.NationalRegisterNumber))
            {
                throw new CustomBadRequestException(ExceptionMessage.IdCardInvalidNiss);
            }

            if (idCard.CalculateAge(DateTime.Today) < MinimumAge)
            {
                throw new CustomBadRequestException(ExceptionMessage.MemberInvalidAge);
            }
        }