-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Security.Cryptography; | ||
using Xunit; | ||
|
||
namespace FingerprintBuilder.Tests | ||
{ | ||
public class ArrayFingerprintBuilderTests | ||
{ | ||
[Fact] | ||
public void UserInfo_Sha1() | ||
{ | ||
var fingerprint = FingerprintBuilder<UserInfo> | ||
.Create(SHA1.Create().ComputeHash) | ||
.For(p => p.Name) | ||
.For(p => p.Emails) | ||
.Build(); | ||
|
||
var user = new UserInfo { Name = "John", Emails = new[] { "[email protected]", "[email protected]" } }; | ||
|
||
var hash = fingerprint(user).ToLowerHexString(); | ||
|
||
Assert.Equal("365993bbd89e2e25039848e51904679cc9e13d17", hash); | ||
} | ||
|
||
[Fact] | ||
public void UserInfo_EmailsString_Sha1() | ||
{ | ||
var fingerprint = FingerprintBuilder<UserInfo> | ||
.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[] { "[email protected]", "[email protected]" } }; | ||
|
||
var hash = fingerprint(user).ToLowerHexString(); | ||
|
||
Assert.Equal("9f825a64a3eb7a7f0b4887ce09ad2a76d085a8b0", hash); | ||
} | ||
|
||
private class UserInfo | ||
{ | ||
public string Name { get; set; } | ||
|
||
public string[] Emails { get; set; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters