diff --git a/tests/ArrayFingerprintBuilderTests.cs b/tests/ArrayFingerprintBuilderTests.cs new file mode 100644 index 0000000..d0b3686 --- /dev/null +++ b/tests/ArrayFingerprintBuilderTests.cs @@ -0,0 +1,47 @@ +using System.Security.Cryptography; +using Xunit; + +namespace FingerprintBuilder.Tests +{ + public class ArrayFingerprintBuilderTests + { + [Fact] + public void UserInfo_Sha1() + { + var fingerprint = FingerprintBuilder + .Create(SHA1.Create().ComputeHash) + .For(p => p.Name) + .For(p => p.Emails) + .Build(); + + var user = new UserInfo { Name = "John", Emails = new[] { "test@test.com", "test1@test.com" } }; + + var hash = fingerprint(user).ToLowerHexString(); + + Assert.Equal("365993bbd89e2e25039848e51904679cc9e13d17", hash); + } + + [Fact] + public void UserInfo_EmailsString_Sha1() + { + var fingerprint = FingerprintBuilder + .Create(SHA1.Create().ComputeHash) + .For(p => p.Name) + .For(p => p.Emails, emails=> string.Join('|', emails)) + .Build(); + + var user = new UserInfo { Name = "John", Emails = new[] { "test@test.com", "test1@test.com" } }; + + var hash = fingerprint(user).ToLowerHexString(); + + Assert.Equal("9f825a64a3eb7a7f0b4887ce09ad2a76d085a8b0", hash); + } + + private class UserInfo + { + public string Name { get; set; } + + public string[] Emails { get; set; } + } + } +} diff --git a/tests/FingerprintBuilder.Tests.csproj b/tests/FingerprintBuilder.Tests.csproj index 509a7c4..138c690 100644 --- a/tests/FingerprintBuilder.Tests.csproj +++ b/tests/FingerprintBuilder.Tests.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0 false diff --git a/tests/FingerprintBuilderTests.cs b/tests/SimpleFingerprintBuilderTests.cs similarity index 98% rename from tests/FingerprintBuilderTests.cs rename to tests/SimpleFingerprintBuilderTests.cs index 126eee4..b15ba7a 100644 --- a/tests/FingerprintBuilderTests.cs +++ b/tests/SimpleFingerprintBuilderTests.cs @@ -3,7 +3,7 @@ namespace FingerprintBuilder.Tests { - public class FingerprintBuilderTests + public class SimpleFingerprintBuilderTests { [Fact] public void UserInfo_Sha1()