88
99namespace AdvancedSystems . Security . Tests . Cryptography ;
1010
11- public class HashTests
11+ /// <summary>
12+ /// Tests the public methods in <seealso cref="Hash"/>.
13+ /// </summary>
14+ public sealed class HashTests
1215{
1316 #region Tests
1417
18+ /// <summary>
19+ /// Tests that the computed <seealso cref="HashAlgorithmName.MD5"/> hash returns a well-formatted string.
20+ /// </summary>
21+ /// <param name="input">
22+ /// The input to compute the hash code for.
23+ /// </param>
24+ /// <param name="expected">
25+ /// The expected result.
26+ /// </param>
27+ /// <param name="format">
28+ /// The formatting to use.
29+ /// </param>
1530 [ Theory ]
1631 [ InlineData ( "Hello, World!" , "65a8e27d8879283831b664bd8b7f0ad4" , Format . Hex ) ]
1732 [ InlineData ( "Hello, World!" , "ZajifYh5KDgxtmS9i38K1A==" , Format . Base64 ) ]
@@ -31,6 +46,18 @@ public void TestMd5Hash(string input, string expected, Format format)
3146 Assert . Equal ( expected , md5 ) ;
3247 }
3348
49+ /// <summary>
50+ /// Tests that the computed <seealso cref="HashAlgorithmName.SHA1"/> hash returns a well-formatted string.
51+ /// </summary>
52+ /// <param name="input">
53+ /// The input to compute the hash code for.
54+ /// </param>
55+ /// <param name="expected">
56+ /// The expected result.
57+ /// </param>
58+ /// <param name="format">
59+ /// The formatting to use.
60+ /// </param>
3461 [ Theory ]
3562 [ InlineData ( "Hello, World!" , "0a0a9f2a6772942557ab5355d76af442f8f65e01" , Format . Hex ) ]
3663 [ InlineData ( "Hello, World!" , "CgqfKmdylCVXq1NV12r0Qvj2XgE=" , Format . Base64 ) ]
@@ -50,6 +77,18 @@ public void TestSHA1Hash(string input, string expected, Format format)
5077 Assert . Equal ( expected , sha1 ) ;
5178 }
5279
80+ /// <summary>
81+ /// Tests that the computed <seealso cref="HashAlgorithmName.SHA256"/> hash returns a well-formatted string.
82+ /// </summary>
83+ /// <param name="input">
84+ /// The input to compute the hash code for.
85+ /// </param>
86+ /// <param name="expected">
87+ /// The expected result.
88+ /// </param>
89+ /// <param name="format">
90+ /// The formatting to use.
91+ /// </param>
5392 [ Theory ]
5493 [ InlineData ( "Hello, World!" , "dffd6021bb2bd5b0af676290809ec3a53191dd81c7f70a4b28688a362182986f" , Format . Hex ) ]
5594 [ InlineData ( "Hello, World!" , "3/1gIbsr1bCvZ2KQgJ7DpTGR3YHH9wpLKGiKNiGCmG8=" , Format . Base64 ) ]
@@ -69,6 +108,18 @@ public void TestSHA256Hash(string input, string expected, Format format)
69108 Assert . Equal ( expected , sha256 ) ;
70109 }
71110
111+ /// <summary>
112+ /// Tests that the computed <seealso cref="HashAlgorithmName.SHA384"/> hash returns a well-formatted string.
113+ /// </summary>
114+ /// <param name="input">
115+ /// The input to compute the hash code for.
116+ /// </param>
117+ /// <param name="expected">
118+ /// The expected result.
119+ /// </param>
120+ /// <param name="format">
121+ /// The formatting to use.
122+ /// </param>
72123 [ Theory ]
73124 [ InlineData ( "Hello, World!" , "5485cc9b3365b4305dfb4e8337e0a598a574f8242bf17289e0dd6c20a3cd44a089de16ab4ab308f63e44b1170eb5f515" , Format . Hex ) ]
74125 [ InlineData ( "Hello, World!" , "VIXMmzNltDBd+06DN+ClmKV0+CQr8XKJ4N1sIKPNRKCJ3harSrMI9j5EsRcOtfUV" , Format . Base64 ) ]
@@ -88,6 +139,18 @@ public void TestSHA384Hash(string input, string expected, Format format)
88139 Assert . Equal ( expected , sha384 ) ;
89140 }
90141
142+ /// <summary>
143+ /// Tests that the computed <seealso cref="HashAlgorithmName.SHA512"/> hash returns a well-formatted string.
144+ /// </summary>
145+ /// <param name="input">
146+ /// The input to compute the hash code for.
147+ /// </param>
148+ /// <param name="expected">
149+ /// The expected result.
150+ /// </param>
151+ /// <param name="format">
152+ /// The formatting to use.
153+ /// </param>
91154 [ Theory ]
92155 [ InlineData ( "Hello, World!" , "374d794a95cdcfd8b35993185fef9ba368f160d8daf432d08ba9f1ed1e5abe6cc69291e0fa2fe0006a52570ef18c19def4e617c33ce52ef0a6e5fbe318cb0387" , Format . Hex ) ]
93156 [ InlineData ( "Hello, World!" , "N015SpXNz9izWZMYX++bo2jxYNja9DLQi6nx7R5avmzGkpHg+i/gAGpSVw7xjBne9OYXwzzlLvCm5fvjGMsDhw==" , Format . Base64 ) ]
0 commit comments