Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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)));
        }
Exemplo n.º 9
0
        public void NationalityField(string mrzLine2, string nationality)
        {
            var model = new MrzLine2Model(mrzLine2);

            Assert.AreEqual(nationality, model.Nationality);
        }
Exemplo n.º 10
0
        public void PassportNumberCheckDigitField(string mrzLine2, byte passportNumberCheckDigit)
        {
            var model = new MrzLine2Model(mrzLine2);

            Assert.AreEqual(passportNumberCheckDigit, model.PassportNumberCheckDigit);
        }
Exemplo n.º 11
0
        public void PassportNumberField(string mrzLine2, string passportNumber)
        {
            var model = new MrzLine2Model(mrzLine2);

            Assert.AreEqual(passportNumber, model.PassportNumber);
        }