Skip to content

Commit

Permalink
update a few things
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackbaud-JaminQuimby authored and binaryfog committed Sep 26, 2020
1 parent 4ac56d2 commit 035629e
Show file tree
Hide file tree
Showing 39 changed files with 560 additions and 521 deletions.
19 changes: 10 additions & 9 deletions BinaryFog.NameParser.Tests/BinaryFog.NameParser.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,34 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ApplicationIcon />
<OutputTypeEx>library</OutputTypeEx>
<StartupObject></StartupObject>
<StartupObject></StartupObject>
<Version>2.0.0</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="RandomNameGeneratorLibrary" Version="1.2.2">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit" Version="2.3.1">
<PackageReference Include="xunit" Version="2.4.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.console" Version="2.3.1">
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.reporters" Version="2.3.1">
<PackageReference Include="xunit.runner.reporters" Version="2.4.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.utility" Version="2.3.1">
<PackageReference Include="xunit.runner.utility" Version="2.4.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1">
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
34 changes: 17 additions & 17 deletions BinaryFog.NameParser.Tests/USRepresentativesTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Diagnostics;
using System.Linq;
using Xunit;

Expand All @@ -13,41 +12,42 @@ public class USRepresentativesTests

public static IEnumerable<object[]> GetUSRepresentatives()
{
var j = JObject.Parse(DataFiles.GetJsonString("USRepresentatives.json"));
var j = JObject.Parse(DataFiles.GetJsonString("USRepresentatives.json")!);

return ( from e in j["objects"]
select new object[]
{
e["person"]["firstname"].ToString(),
e["person"]["lastname"].ToString(),
e["person"]["name"].ToString(),
e["person"]["nickname"].ToString(),
}).ToArray();
return (j["objects"]!
.Select(e => new object[]
{
e["person"]?["firstname"]?.ToString(),
e["person"]?["lastname"]?.ToString(),
e["person"]?["name"]?.ToString(),
e["person"]?["nickname"]?.ToString(),
})).ToArray();
}

[Theory]
[MemberData(nameof(GetUSRepresentatives),DisableDiscoveryEnumeration = true)]
public void GetUSRepresentatives_Test( string firstName, string lastName, string name, string nickname)
[MemberData(nameof(GetUSRepresentatives),DisableDiscoveryEnumeration = true)]
public void GetUSRepresentatives_Test(string firstName, string lastName, string name, string nickname)
{
//ARRANGE
//Remove party suffix
int i = name.IndexOf('[');
string nameWithoutParty = name.Substring(0, i).Trim();
Debug.Assert(name != null, nameof(name) + " != null");
var i = name.IndexOf('[');
var nameWithoutParty = name.Substring(0, i).Trim();

//ACT
var target = new FullNameParser(nameWithoutParty);
target.Parse();

//ASSERT
Assert.Equal( firstName, target.FirstName);
Assert.Equal( lastName, target.LastName);
Assert.Equal( lastName, target.LastName);

if( lastName == "González-Colón")
Assert.Equal("Commish.", target.Title);
else
Assert.Equal("Rep.", target.Title);

if (String.IsNullOrEmpty( nickname ))
if (string.IsNullOrEmpty( nickname ))
Assert.Null(target.NickName);
else
Assert.Equal(nickname, target.NickName);
Expand Down
4 changes: 2 additions & 2 deletions BinaryFog.NameParser.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.15
# Visual Studio Version 16
VisualStudioVersion = 16.0.30503.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BinaryFog.NameParser", "BinaryFog.NameParser\BinaryFog.NameParser.csproj", "{5BCB7AA3-D399-4246-A8B9-E88F1FB15465}"
EndProject
Expand Down
16 changes: 8 additions & 8 deletions BinaryFog.NameParser/BinaryFog.NameParser.csproj
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFramework>netstandard2.1</TargetFramework>
<Company>BinaryFog.com</Company>
<Authors>BinaryFog</Authors>
<Description>Human name parsing.
Parses names using English conventions for persons names.
Many thanks to Tyler Young, Matt Gillette, mguiness,Paul Forness</Description>
<Copyright>Copyright © BinaryFog.com 2015 - 2019</Copyright>
<Copyright>Copyright © BinaryFog.com 2015 - 2020</Copyright>
<Version>2.5.1</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<PackageProjectUrl>https://github.com/binaryfog/NameParser</PackageProjectUrl>
Expand All @@ -28,8 +28,8 @@ Many thanks to Tyler Young, Matt Gillette, mguiness,Paul Forness</Description>
<AssemblyOriginatorKeyFile>..\..\BenefitAgent\src\key.pfx</AssemblyOriginatorKeyFile>
<PackageReleaseNotes>Last Name, First Name Initial Pattern added.</PackageReleaseNotes>
<PackageTags>Name parser, name parsing</PackageTags>
<AssemblyVersion>2.5.1.0</AssemblyVersion>
<FileVersion>2.5.1.0</FileVersion>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
<ItemGroup>
Expand All @@ -45,7 +45,7 @@ Many thanks to Tyler Young, Matt Gillette, mguiness,Paul Forness</Description>
</ItemGroup>

<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.0.0">
<PackageReference Include="JetBrains.Annotations" Version="2020.1.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.PlatformAbstractions" Version="1.1.0">
Expand All @@ -54,7 +54,7 @@ Many thanks to Tyler Young, Matt Gillette, mguiness,Paul Forness</Description>
<PackageReference Include="System.Collections" Version="4.3.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Collections.Immutable" Version="1.4.0">
<PackageReference Include="System.Collections.Immutable" Version="1.7.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Diagnostics.Debug" Version="4.3.0">
Expand All @@ -72,10 +72,10 @@ Many thanks to Tyler Young, Matt Gillette, mguiness,Paul Forness</Description>
<PackageReference Include="System.Linq" Version="4.3.0">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Runtime" Version="4.3.0">
<PackageReference Include="System.Runtime" Version="4.3.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Runtime.Extensions" Version="4.3.0">
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0">
Expand Down
34 changes: 18 additions & 16 deletions BinaryFog.NameParser/IFullNamePattern.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
namespace BinaryFog.NameParser {
/// <summary>
/// Implement this interface if you wish for your name parser pattern
/// to be automatically discovered and used by the <see cref="FullNameParser"/>.
///
/// The implementing class must be public to be discovered automatically.
///
/// Feel free to submit your patterns upstream to the repository or create a separate pattern library.
/// </summary>
public interface IFullNamePattern {
/// <summary>
/// Attempt to parse a name through the pattern.
/// </summary>
/// <param name="rawName">A raw name.</param>
/// <returns>A scored parsed result.</returns>
ParsedFullName Parse(string rawName);
/// <summary>
/// Implement this interface if you wish for your name parser pattern
/// to be automatically discovered and used by the <see cref="FullNameParser"/>.
///
/// The implementing class must be public to be discovered automatically.
///
/// Feel free to submit your patterns upstream to the repository or create a separate pattern library.
/// </summary>
public interface IFullNamePattern
{

}
/// <summary>
/// Attempt to parse a name through the pattern.
/// </summary>
/// <param name="rawName">A raw name.</param>
/// <returns>A scored parsed result.</returns>
ParsedFullName Parse(string rawName);

}
}
Loading

0 comments on commit 035629e

Please sign in to comment.