Skip to content

Commit

Permalink
Add Florida test
Browse files Browse the repository at this point in the history
  • Loading branch information
c0shea committed Sep 30, 2017
1 parent c57a5a6 commit c59f311
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 6 deletions.
42 changes: 41 additions & 1 deletion IdParser.Test/DriversLicenseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public void TestMOLicense()
Assert.IsNotNull(idCard);

Assert.AreEqual("FirstNameTest", idCard.FirstName);
Assert.AreEqual(" ", idCard.MiddleName);
Assert.IsNull(idCard.MiddleName);
Assert.AreEqual("LastNameTest", idCard.LastName);

Assert.AreEqual("123 ABC TEST ADDRESS 2ND FL", idCard.StreetLine1);
Expand Down Expand Up @@ -293,5 +293,45 @@ public void TestMOLicense()
Assert.AreEqual("F", license.Jurisdiction.VehicleClass);
}
}

[TestMethod]
public void TestFLLicense()
{
var file = File.ReadAllText("FL License.txt");
var idCard = Barcode.Parse(file, Validation.None);

Assert.IsNotNull(idCard);

Assert.AreEqual("JOEY", idCard.FirstName);
Assert.AreEqual("MIDLAND", idCard.MiddleName);
Assert.AreEqual("TESTER", idCard.LastName);

Assert.AreEqual("1234 PARK ST LOT 504", idCard.StreetLine1);
Assert.AreEqual("KEY WEST", idCard.City);
Assert.AreEqual("FL", idCard.IssuerIdentificationNumber.GetAbbreviation());
Assert.AreEqual("FL", idCard.JurisdictionCode);
Assert.AreEqual("330400504", idCard.PostalCode);
Assert.AreEqual("33040-0504", idCard.FormattedPostalCode);
Assert.AreEqual(Country.USA, idCard.Country);

Assert.AreEqual(new DateTime(1941, 05, 09), idCard.DateOfBirth);
Assert.AreEqual(Sex.Male, idCard.Sex);
Assert.AreEqual(73, idCard.Height.TotalInches);
Assert.AreEqual(WeightRange.None, idCard.WeightRange);

Assert.AreEqual("H574712510891", idCard.IdNumber);
Assert.AreEqual(Version.Aamva2000, idCard.AamvaVersionNumber);
Assert.AreEqual(new DateTime(2014, 05, 01), idCard.IssueDate);
Assert.AreEqual(new DateTime(2022, 03, 09), idCard.ExpirationDate);

Assert.AreEqual(5, idCard.AdditionalJurisdictionElements.Count);
Assert.AreEqual("FA", idCard.AdditionalJurisdictionElements.Single(e => e.Key == "ZFZ").Value);

if (idCard is DriversLicense license)
{
Assert.AreEqual("A", license.Jurisdiction.RestrictionCodes);
Assert.AreEqual("E", license.Jurisdiction.VehicleClass);
}
}
}
}
21 changes: 21 additions & 0 deletions IdParser.Test/FL License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@

ANSI 6360100102DL00390187ZF02260043DLDAATESTER,JOEY, MIDLAND
DAG1234 PARK ST LOT 504
DAIKEY WEST
DAJFL
DAK33040-0504
DAQH574712510891
DARE
DASA
DATNONE
DBA20220309
DBB19410509
DBC1
DBD20140501
DAU601
ZFZFA
ZFB
ZFCN899999999077
ZFD
ZFE09-01-12
3 changes: 3 additions & 0 deletions IdParser.Test/IdParser.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@
<Content Include="CT License.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="FL License.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="GA License.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
Expand Down
5 changes: 5 additions & 0 deletions IdParser/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,10 @@ internal static DateTime ParseDate(this Country country, Version version, string

throw new ArgumentException($"Failed to parse the date '{value}' for country '{country}' using version '{version}'.", nameof(value));
}

internal static string ReplaceEmptyWithNull(this string data)
{
return string.IsNullOrEmpty(data) ? null : data;
}
}
}
10 changes: 5 additions & 5 deletions IdParser/IdentificationCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,17 @@ private void ParseRecord(string subfileRecord)
// Required attributes
case "DAA":
var names = data.Split(',', '$');
LastName = names.Length > 0 ? names[0].Trim() : null;
FirstName = names.Length > 1 ? names[1].Trim() : null;
MiddleName = names.Length > 2 ? names[2].Trim() : null;
LastName = names.Length > 0 ? names[0].Trim().ReplaceEmptyWithNull() : null;
FirstName = names.Length > 1 ? names[1].Trim().ReplaceEmptyWithNull() : null;
MiddleName = names.Length > 2 ? names[2].Trim().ReplaceEmptyWithNull() : null;

break;

// AAMVA 2003-2005
case "DCT":
var givenNames = data.Split(',', '$', ' ');
FirstName = givenNames[0];
MiddleName = givenNames.Length > 1 ? givenNames[1] : null;
FirstName = givenNames[0].Trim();
MiddleName = givenNames.Length > 1 ? givenNames[1].Trim().ReplaceEmptyWithNull() : null;

break;

Expand Down

0 comments on commit c59f311

Please sign in to comment.