示例#1
0
        public void DateOfBirthCrossCheck(string mrzLine2, DateTime compareDateOfBirth, bool expectedResult)
        {
            var model  = new MrzLine2Model(mrzLine2);
            var result = model.Verify(dateOfBirth: compareDateOfBirth);

            Assert.AreEqual(expectedResult, result.DateOfBirthCrossChecked);
        }
示例#2
0
        public void NationalityCrossCheck(string mrzLine2, string compareNationality, bool expectedResult)
        {
            var model  = new MrzLine2Model(mrzLine2);
            var result = model.Verify(nationality: compareNationality);

            Assert.AreEqual(expectedResult, result.NationalityCrossChecked);
        }
示例#3
0
        public void GenderCrossCheck(string mrzLine2, Constants.Gender?compareGender, bool expectedResult)
        {
            var model  = new MrzLine2Model(mrzLine2);
            var result = model.Verify(gender: compareGender);

            Assert.AreEqual(expectedResult, result.GenderCrossChecked);
        }
示例#4
0
        public void PassportNumberCrossCheck(string mrzLine2, string comparePassportNumber, bool expectedResult)
        {
            var model  = new MrzLine2Model(mrzLine2);
            var result = model.Verify(comparePassportNumber);

            Assert.AreEqual(expectedResult, result.PassportNumberCrossChecked);
        }
示例#5
0
        public void ExpirationDateCrossCheck(string mrzLine2, DateTime compareExpirationDate, bool expectedResult)
        {
            var model  = new MrzLine2Model(mrzLine2);
            var result = model.Verify(expirationDate: compareExpirationDate);

            Assert.AreEqual(expectedResult, result.PassportExpirtaionDateCrossChecked);
        }
示例#6
0
        // POST: api/Passport
        public IHttpActionResult Post([FromBody] PassportVerificationInputDTO parameters)
        {
            if (!ModelState.IsValid)
            {
                var validationErrorReport = new System.Text.StringBuilder();
                validationErrorReport.AppendLine("Invalid Passport Verification Input");
                foreach (var inputParam in ModelState)
                {
                    validationErrorReport.AppendLine(inputParam.Key);
                    validationErrorReport.AppendLine($"Value: {inputParam.Value.Value}");
                    foreach (var modelError in inputParam.Value.Errors)
                    {
                        validationErrorReport.AppendLine($"Error: {modelError.ErrorMessage}");
                    }
                }
                ErrorLogService.LogWarning(validationErrorReport.ToString());
                return(BadRequest(ModelState));
            }

            var model = new MrzLine2Model(parameters.MrzLine2);

            return(Ok(model.Verify(parameters.PassportNumber,
                                   parameters.Nationality,
                                   parameters.DOB,
                                   parameters.Gender,
                                   parameters.ExpirationDate)));
        }
示例#7
0
        public void AllCheckDigitVerifyFail(string mrzLine2)
        {
            var model  = new MrzLine2Model(mrzLine2);
            var result = model.Verify();

            Assert.AreEqual(false, result.DateOfBirthCheckDigitValid);
            Assert.AreEqual(false, result.PassportExpirationDateCheckDigitValid);
            Assert.AreEqual(false, result.PassportNumberCheckDigitValid);
            Assert.AreEqual(false, result.PersonalNumberCheckDigitValid);
            Assert.AreEqual(false, result.FinalCheckDigitValid);
        }
示例#8
0
        // GET: api/Passport/5
        public IHttpActionResult Get([FromUri] PassportVerificationInputDTO parameters)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var model = new MrzLine2Model(parameters.MrzLine2);

            return(Ok(model.Verify(parameters.PassportNumber,
                                   parameters.Nationality,
                                   parameters.DOB,
                                   parameters.Gender,
                                   parameters.ExpirationDate)));
        }