Testing and Password

This commit is contained in:
Jordan Wages 2024-08-27 18:54:36 -05:00
parent 746ac82051
commit 650c6ea3dd
33 changed files with 1191 additions and 5 deletions

View file

@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "Documentation", "..\Documentation\Documentation.shfbproj", "{E23D3844-E594-487E-979B-2D35B1B9AAE8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "..\Tests\Tests.csproj", "{D142EF3D-8F61-40B6-8358-7D5B7F8A2B18}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -26,6 +28,10 @@ Global
{E23D3844-E594-487E-979B-2D35B1B9AAE8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E23D3844-E594-487E-979B-2D35B1B9AAE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E23D3844-E594-487E-979B-2D35B1B9AAE8}.Release|Any CPU.Build.0 = Release|Any CPU
{D142EF3D-8F61-40B6-8358-7D5B7F8A2B18}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D142EF3D-8F61-40B6-8358-7D5B7F8A2B18}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D142EF3D-8F61-40B6-8358-7D5B7F8A2B18}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D142EF3D-8F61-40B6-8358-7D5B7F8A2B18}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View file

@ -47,7 +47,7 @@ namespace CapyKit
{
return pbkdf2Algorithm.Value;
}
}
}
#endregion
@ -58,7 +58,7 @@ namespace CapyKit
/// <param name="salt"> The salt used for encryption. </param>
/// <param name="algorithm"> The algorithm used for password encryption. </param>
/// <param name="args"> A variable-length parameters list containing arguments to include for the <paramref name="algorithm"/>. </param>
internal Password(string password, byte[] salt, IPasswordAlgorithm algorithm, params object[] args)
public Password(string password, byte[] salt, IPasswordAlgorithm algorithm, params object[] args)
{
// We know there will always be a salt, so we can prepend it to h
var augmented = args.Prepend(salt).ToArray();
@ -85,8 +85,8 @@ namespace CapyKit
}
return this.Algorithm.AlgorithmName == objPassword.Algorithm.AlgorithmName
&& this.Hash == objPassword.Hash
&& this.Salt == objPassword.Salt;
&& this.Hash.SequenceEqual(objPassword.Hash)
&& this.Salt.SequenceEqual(objPassword.Salt);
}
/// <inheritdoc/>

View file

@ -0,0 +1,31 @@
# Replacement Field
\[Missing &lt;summary&gt; documentation for "F:Tests.StringExtensions.Replacement"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
private const string Replacement = "Replaced"
```
**F#**
``` F#
static val mutable private Replacement: string
```
#### Field Value
<a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,18 @@
# StringExtensions Fields
## Fields
<table>
<tr>
<td><a href="F_Tests_StringExtensions_Replacement.md">Replacement</a></td>
<td> </td></tr>
</table>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -11,7 +11,7 @@ Constructor.
**C#**
``` C#
internal Password(
public Password(
string password,
byte[] salt,
IPasswordAlgorithm algorithm,

View file

@ -0,0 +1,42 @@
# GenerateSalt Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.GenerateSalt(System.Int32)"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
private static byte[] GenerateSalt(
int size = 16
)
```
**F#**
``` F#
private static member GenerateSalt :
?size : int
(* Defaults:
let _size = defaultArg size 16
*)
-> byte[]
```
#### Parameters
<dl><dt>  <a href="https://learn.microsoft.com/dotnet/api/system.int32" target="_blank" rel="noopener noreferrer">Int32</a>  (Optional)</dt><dd>\[Missing &lt;param name="size"/&gt; documentation for "M:Tests.Passwords.PasswordTests.GenerateSalt(System.Int32)"\]</dd></dl>
#### Return Value
<a href="https://learn.microsoft.com/dotnet/api/system.byte" target="_blank" rel="noopener noreferrer">Byte</a>[]
\[Missing &lt;returns&gt; documentation for "M:Tests.Passwords.PasswordTests.GenerateSalt(System.Int32)"\]
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# PasswordCreation_WithInvalidSalt_ReturnsEmptyHash Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.PasswordCreation_WithInvalidSalt_ReturnsEmptyHash"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestAttribute]
public void PasswordCreation_WithInvalidSalt_ReturnsEmptyHash()
```
**F#**
``` F#
[<TestAttribute>]
member PasswordCreation_WithInvalidSalt_ReturnsEmptyHash : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestAttribute]
public void PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash()
```
**F#**
``` F#
[<TestAttribute>]
member PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# PasswordEquality_DifferentPasswords_AreNotEqual Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.PasswordEquality_DifferentPasswords_AreNotEqual"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestAttribute]
public void PasswordEquality_DifferentPasswords_AreNotEqual()
```
**F#**
``` F#
[<TestAttribute>]
member PasswordEquality_DifferentPasswords_AreNotEqual : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# PasswordEquality_DifferentSalts_AreNotEqual Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.PasswordEquality_DifferentSalts_AreNotEqual"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestAttribute]
public void PasswordEquality_DifferentSalts_AreNotEqual()
```
**F#**
``` F#
[<TestAttribute>]
member PasswordEquality_DifferentSalts_AreNotEqual : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# PasswordEquality_SamePasswordAndSalt_AreEqual Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.PasswordEquality_SamePasswordAndSalt_AreEqual"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestAttribute]
public void PasswordEquality_SamePasswordAndSalt_AreEqual()
```
**F#**
``` F#
[<TestAttribute>]
member PasswordEquality_SamePasswordAndSalt_AreEqual : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# ToString_ReturnsCorrectFormat Method
\[Missing &lt;summary&gt; documentation for "M:Tests.Passwords.PasswordTests.ToString_ReturnsCorrectFormat"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestAttribute]
public void ToString_ReturnsCorrectFormat()
```
**F#**
``` F#
[<TestAttribute>]
member ToString_ReturnsCorrectFormat : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,28 @@
# Passwords.PasswordTests Constructor
Initializes a new instance of the <a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests</a> class
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
public PasswordTests()
```
**F#**
``` F#
new : unit -> PasswordTests
```
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,28 @@
# Passwords Constructor
Initializes a new instance of the <a href="T_Tests_Passwords.md">Passwords</a> class
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
public Passwords()
```
**F#**
``` F#
new : unit -> Passwords
```
## See Also
#### Reference
<a href="T_Tests_Passwords.md">Passwords Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,38 @@
# IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty Method
\[Missing &lt;summary&gt; documentation for "M:Tests.StringExtensions.IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty(System.String)"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestCaseAttribute("Not Empty")]
[TestCaseAttribute("")]
public void IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty(
string value
)
```
**F#**
``` F#
[<TestCaseAttribute("Not Empty")>]
[<TestCaseAttribute("")>]
member IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty :
value : string -> unit
```
#### Parameters
<dl><dt>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>\[Missing &lt;param name="value"/&gt; documentation for "M:Tests.StringExtensions.IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty(System.String)"\]</dd></dl>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,36 @@
# IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty Method
\[Missing &lt;summary&gt; documentation for "M:Tests.StringExtensions.IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty(System.String)"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestCaseAttribute("")]
public void IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty(
string value
)
```
**F#**
``` F#
[<TestCaseAttribute("")>]
member IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty :
value : string -> unit
```
#### Parameters
<dl><dt>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>\[Missing &lt;param name="value"/&gt; documentation for "M:Tests.StringExtensions.IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty(System.String)"\]</dd></dl>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,38 @@
# IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace Method
\[Missing &lt;summary&gt; documentation for "M:Tests.StringExtensions.IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace(System.String)"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestCaseAttribute("Not Empty")]
[TestCaseAttribute(" Tab")]
public void IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace(
string value
)
```
**F#**
``` F#
[<TestCaseAttribute("Not Empty")>]
[<TestCaseAttribute(" Tab")>]
member IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace :
value : string -> unit
```
#### Parameters
<dl><dt>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>\[Missing &lt;param name="value"/&gt; documentation for "M:Tests.StringExtensions.IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace(System.String)"\]</dd></dl>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,38 @@
# IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace Method
\[Missing &lt;summary&gt; documentation for "M:Tests.StringExtensions.IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace(System.String)"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestCaseAttribute("")]
[TestCaseAttribute("")]
public void IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace(
string value
)
```
**F#**
``` F#
[<TestCaseAttribute("")>]
[<TestCaseAttribute("")>]
member IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace :
value : string -> unit
```
#### Parameters
<dl><dt>  <a href="https://learn.microsoft.com/dotnet/api/system.string" target="_blank" rel="noopener noreferrer">String</a></dt><dd>\[Missing &lt;param name="value"/&gt; documentation for "M:Tests.StringExtensions.IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace(System.String)"\]</dd></dl>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,30 @@
# Setup Method
\[Missing &lt;summary&gt; documentation for "M:Tests.StringExtensions.Setup"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[SetUpAttribute]
public void Setup()
```
**F#**
``` F#
[<SetUpAttribute>]
member Setup : unit -> unit
```
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,28 @@
# StringExtensions Constructor
Initializes a new instance of the <a href="T_Tests_StringExtensions.md">StringExtensions</a> class
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
public StringExtensions()
```
**F#**
``` F#
new : unit -> StringExtensions
```
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,33 @@
# Passwords Methods
## Methods
<table>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)" target="_blank" rel="noopener noreferrer">Equals</a></td>
<td>Determines whether the specified object is equal to the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.finalize" target="_blank" rel="noopener noreferrer">Finalize</a></td>
<td>Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode" target="_blank" rel="noopener noreferrer">GetHashCode</a></td>
<td>Serves as the default hash function.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype" target="_blank" rel="noopener noreferrer">GetType</a></td>
<td>Gets the <a href="https://learn.microsoft.com/dotnet/api/system.type" target="_blank" rel="noopener noreferrer">Type</a> of the current instance.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone" target="_blank" rel="noopener noreferrer">MemberwiseClone</a></td>
<td>Creates a shallow copy of the current <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.tostring" target="_blank" rel="noopener noreferrer">ToString</a></td>
<td>Returns a string that represents the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
</table>
## See Also
#### Reference
<a href="T_Tests_Passwords.md">Passwords Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,54 @@
# PasswordTests Methods
## Methods
<table>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)" target="_blank" rel="noopener noreferrer">Equals</a></td>
<td>Determines whether the specified object is equal to the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.finalize" target="_blank" rel="noopener noreferrer">Finalize</a></td>
<td>Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_GenerateSalt.md">GenerateSalt</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode" target="_blank" rel="noopener noreferrer">GetHashCode</a></td>
<td>Serves as the default hash function.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype" target="_blank" rel="noopener noreferrer">GetType</a></td>
<td>Gets the <a href="https://learn.microsoft.com/dotnet/api/system.type" target="_blank" rel="noopener noreferrer">Type</a> of the current instance.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone" target="_blank" rel="noopener noreferrer">MemberwiseClone</a></td>
<td>Creates a shallow copy of the current <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordCreation_WithInvalidSalt_ReturnsEmptyHash.md">PasswordCreation_WithInvalidSalt_ReturnsEmptyHash</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash.md">PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordEquality_DifferentPasswords_AreNotEqual.md">PasswordEquality_DifferentPasswords_AreNotEqual</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordEquality_DifferentSalts_AreNotEqual.md">PasswordEquality_DifferentSalts_AreNotEqual</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordEquality_SamePasswordAndSalt_AreEqual.md">PasswordEquality_SamePasswordAndSalt_AreEqual</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.tostring" target="_blank" rel="noopener noreferrer">ToString</a></td>
<td>Returns a string that represents the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_ToString_ReturnsCorrectFormat.md">ToString_ReturnsCorrectFormat</a></td>
<td> </td></tr>
</table>
## See Also
#### Reference
<a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,48 @@
# StringExtensions Methods
## Methods
<table>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)" target="_blank" rel="noopener noreferrer">Equals</a></td>
<td>Determines whether the specified object is equal to the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.finalize" target="_blank" rel="noopener noreferrer">Finalize</a></td>
<td>Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode" target="_blank" rel="noopener noreferrer">GetHashCode</a></td>
<td>Serves as the default hash function.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype" target="_blank" rel="noopener noreferrer">GetType</a></td>
<td>Gets the <a href="https://learn.microsoft.com/dotnet/api/system.type" target="_blank" rel="noopener noreferrer">Type</a> of the current instance.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty.md">IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty.md">IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace.md">IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace.md">IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone" target="_blank" rel="noopener noreferrer">MemberwiseClone</a></td>
<td>Creates a shallow copy of the current <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_Setup.md">Setup</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.tostring" target="_blank" rel="noopener noreferrer">ToString</a></td>
<td>Returns a string that represents the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
</table>
## See Also
#### Reference
<a href="T_Tests_StringExtensions.md">StringExtensions Class</a>
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,19 @@
# Tests Namespace
\[Missing &lt;summary&gt; documentation for "N:Tests"\]
## Classes
<table>
<tr>
<td><a href="T_Tests_Passwords.md">Passwords</a></td>
<td> </td></tr>
<tr>
<td><a href="T_Tests_Passwords_PasswordTests.md">Passwords.PasswordTests</a></td>
<td> </td></tr>
<tr>
<td><a href="T_Tests_StringExtensions.md">StringExtensions</a></td>
<td> </td></tr>
</table>

View file

@ -20,4 +20,7 @@
<tr>
<td><a href="N_CapyKit_Helpers.md">CapyKit.Helpers</a></td>
<td /></tr>
<tr>
<td><a href="N_Tests.md">Tests</a></td>
<td /></tr>
</table>

View file

@ -0,0 +1,59 @@
# Passwords Class
\[Missing &lt;summary&gt; documentation for "T:Tests.Passwords"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
internal class Passwords
```
**F#**
``` F#
type Passwords = class end
```
<table><tr><td><strong>Inheritance</strong></td><td><a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a> → Passwords</td></tr>
</table>
## Constructors
<table>
<tr>
<td><a href="M_Tests_Passwords__ctor.md">Passwords</a></td>
<td>Initializes a new instance of the Passwords class</td></tr>
</table>
## Methods
<table>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)" target="_blank" rel="noopener noreferrer">Equals</a></td>
<td>Determines whether the specified object is equal to the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.finalize" target="_blank" rel="noopener noreferrer">Finalize</a></td>
<td>Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode" target="_blank" rel="noopener noreferrer">GetHashCode</a></td>
<td>Serves as the default hash function.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype" target="_blank" rel="noopener noreferrer">GetType</a></td>
<td>Gets the <a href="https://learn.microsoft.com/dotnet/api/system.type" target="_blank" rel="noopener noreferrer">Type</a> of the current instance.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone" target="_blank" rel="noopener noreferrer">MemberwiseClone</a></td>
<td>Creates a shallow copy of the current <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.tostring" target="_blank" rel="noopener noreferrer">ToString</a></td>
<td>Returns a string that represents the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
</table>
## See Also
#### Reference
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,82 @@
# Passwords.PasswordTests Class
\[Missing &lt;summary&gt; documentation for "T:Tests.Passwords.PasswordTests"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestFixtureAttribute]
public class PasswordTests
```
**F#**
``` F#
[<TestFixtureAttribute>]
type PasswordTests = class end
```
<table><tr><td><strong>Inheritance</strong></td><td><a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a> → Passwords.PasswordTests</td></tr>
</table>
## Constructors
<table>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests__ctor.md">Passwords.PasswordTests</a></td>
<td>Initializes a new instance of the Passwords.PasswordTests class</td></tr>
</table>
## Methods
<table>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)" target="_blank" rel="noopener noreferrer">Equals</a></td>
<td>Determines whether the specified object is equal to the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.finalize" target="_blank" rel="noopener noreferrer">Finalize</a></td>
<td>Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_GenerateSalt.md">GenerateSalt</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode" target="_blank" rel="noopener noreferrer">GetHashCode</a></td>
<td>Serves as the default hash function.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype" target="_blank" rel="noopener noreferrer">GetType</a></td>
<td>Gets the <a href="https://learn.microsoft.com/dotnet/api/system.type" target="_blank" rel="noopener noreferrer">Type</a> of the current instance.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone" target="_blank" rel="noopener noreferrer">MemberwiseClone</a></td>
<td>Creates a shallow copy of the current <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordCreation_WithInvalidSalt_ReturnsEmptyHash.md">PasswordCreation_WithInvalidSalt_ReturnsEmptyHash</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash.md">PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordEquality_DifferentPasswords_AreNotEqual.md">PasswordEquality_DifferentPasswords_AreNotEqual</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordEquality_DifferentSalts_AreNotEqual.md">PasswordEquality_DifferentSalts_AreNotEqual</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_PasswordEquality_SamePasswordAndSalt_AreEqual.md">PasswordEquality_SamePasswordAndSalt_AreEqual</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.tostring" target="_blank" rel="noopener noreferrer">ToString</a></td>
<td>Returns a string that represents the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_Passwords_PasswordTests_ToString_ReturnsCorrectFormat.md">ToString_ReturnsCorrectFormat</a></td>
<td> </td></tr>
</table>
## See Also
#### Reference
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,83 @@
# StringExtensions Class
\[Missing &lt;summary&gt; documentation for "T:Tests.StringExtensions"\]
## Definition
**Namespace:** <a href="N_Tests.md">Tests</a>
**Assembly:** Tests (in Tests.exe) Version: 1.0.0
**C#**
``` C#
[TestFixtureAttribute]
internal class StringExtensions
```
**F#**
``` F#
[<TestFixtureAttribute>]
type StringExtensions = class end
```
<table><tr><td><strong>Inheritance</strong></td><td><a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a> → StringExtensions</td></tr>
</table>
## Constructors
<table>
<tr>
<td><a href="M_Tests_StringExtensions__ctor.md">StringExtensions</a></td>
<td>Initializes a new instance of the StringExtensions class</td></tr>
</table>
## Methods
<table>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)" target="_blank" rel="noopener noreferrer">Equals</a></td>
<td>Determines whether the specified object is equal to the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.finalize" target="_blank" rel="noopener noreferrer">Finalize</a></td>
<td>Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gethashcode" target="_blank" rel="noopener noreferrer">GetHashCode</a></td>
<td>Serves as the default hash function.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.gettype" target="_blank" rel="noopener noreferrer">GetType</a></td>
<td>Gets the <a href="https://learn.microsoft.com/dotnet/api/system.type" target="_blank" rel="noopener noreferrer">Type</a> of the current instance.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty.md">IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty.md">IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace.md">IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace</a></td>
<td> </td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace.md">IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone" target="_blank" rel="noopener noreferrer">MemberwiseClone</a></td>
<td>Creates a shallow copy of the current <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
<tr>
<td><a href="M_Tests_StringExtensions_Setup.md">Setup</a></td>
<td> </td></tr>
<tr>
<td><a href="https://learn.microsoft.com/dotnet/api/system.object.tostring" target="_blank" rel="noopener noreferrer">ToString</a></td>
<td>Returns a string that represents the current object.<br />(Inherited from <a href="https://learn.microsoft.com/dotnet/api/system.object" target="_blank" rel="noopener noreferrer">Object</a>)</td></tr>
</table>
## Fields
<table>
<tr>
<td><a href="F_Tests_StringExtensions_Replacement.md">Replacement</a></td>
<td> </td></tr>
</table>
## See Also
#### Reference
<a href="N_Tests.md">Tests Namespace</a>

View file

@ -0,0 +1,19 @@
<doc>
<assembly>
<name>_InheritedDocs_</name>
</assembly>
<members>
<member name="M:CapyKit.Password.Equals(System.Object)">
<summary>Determines whether the specified object is equal to the current object.</summary><param name="obj">The object to compare with the current object.</param><returns><see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" />.</returns></member><member name="M:CapyKit.Password.ToString">
<summary>Returns a string that represents the current object.</summary><returns>A string that represents the current object.</returns></member><member name="M:CapyKit.Password.op_Equality(CapyKit.Password,CapyKit.Password)">
</member><member name="M:CapyKit.Password.op_Inequality(CapyKit.Password,CapyKit.Password)">
</member><member name="P:CapyKit.Pbkdf2Algorithm.AlgorithmName">
<summary>
Gets the name of the algorithm.
</summary></member></members>
</doc>

View file

@ -229,3 +229,27 @@
- [accessor Field](F_CapyKit_Helpers_SettingsHelper_accessor.md)
- [detector Field](F_CapyKit_Helpers_SettingsHelper_detector.md)
- [ValidCharacterCollection Enumeration](T_CapyKit_Helpers_ValidCharacterCollection.md)
- [Tests Namespace](N_Tests.md)
- [Passwords Class](T_Tests_Passwords.md)
- [Passwords Constructor](M_Tests_Passwords__ctor.md)
- [Passwords Methods](Methods_T_Tests_Passwords.md)
- [Passwords.PasswordTests Class](T_Tests_Passwords_PasswordTests.md)
- [Passwords.PasswordTests Constructor](M_Tests_Passwords_PasswordTests__ctor.md)
- [PasswordTests Methods](Methods_T_Tests_Passwords_PasswordTests.md)
- [GenerateSalt Method](M_Tests_Passwords_PasswordTests_GenerateSalt.md)
- [PasswordCreation_WithInvalidSalt_ReturnsEmptyHash Method](M_Tests_Passwords_PasswordTests_PasswordCreation_WithInvalidSalt_ReturnsEmptyHash.md)
- [PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash Method](M_Tests_Passwords_PasswordTests_PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash.md)
- [PasswordEquality_DifferentPasswords_AreNotEqual Method](M_Tests_Passwords_PasswordTests_PasswordEquality_DifferentPasswords_AreNotEqual.md)
- [PasswordEquality_DifferentSalts_AreNotEqual Method](M_Tests_Passwords_PasswordTests_PasswordEquality_DifferentSalts_AreNotEqual.md)
- [PasswordEquality_SamePasswordAndSalt_AreEqual Method](M_Tests_Passwords_PasswordTests_PasswordEquality_SamePasswordAndSalt_AreEqual.md)
- [ToString_ReturnsCorrectFormat Method](M_Tests_Passwords_PasswordTests_ToString_ReturnsCorrectFormat.md)
- [StringExtensions Class](T_Tests_StringExtensions.md)
- [StringExtensions Constructor](M_Tests_StringExtensions__ctor.md)
- [StringExtensions Methods](Methods_T_Tests_StringExtensions.md)
- [IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty Method](M_Tests_StringExtensions_IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty.md)
- [IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty Method](M_Tests_StringExtensions_IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty.md)
- [IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace Method](M_Tests_StringExtensions_IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace.md)
- [IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace Method](M_Tests_StringExtensions_IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace.md)
- [Setup Method](M_Tests_StringExtensions_Setup.md)
- [StringExtensions Fields](Fields_T_Tests_StringExtensions.md)
- [Replacement Field](F_Tests_StringExtensions_Replacement.md)

127
Tests/Passwords.cs Normal file
View file

@ -0,0 +1,127 @@
using CapyKit;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Tests
{
internal class Passwords
{
[TestFixture]
public class PasswordTests
{
private static byte[] GenerateSalt(int size = 16)
{
var salt = new byte[size];
using (var rng = new System.Security.Cryptography.RNGCryptoServiceProvider())
{
rng.GetBytes(salt);
}
return salt;
}
[Test]
public void PasswordCreation_WithPbkdf2Algorithm_CreatesValidHash()
{
// Arrange
var passwordText = "mySecurePassword";
var salt = GenerateSalt();
var algorithm = Password.Pbkdf2Algorithm;
// Act
var password = new Password(passwordText, salt, algorithm);
// Assert
Assert.IsNotNull(password.Hash);
Assert.IsNotEmpty(password.Hash);
Assert.AreEqual(salt, password.Salt);
Assert.AreEqual(algorithm, password.Algorithm);
}
[Test]
public void PasswordEquality_SamePasswordAndSalt_AreEqual()
{
// Arrange
var passwordText = "mySecurePassword";
var salt = GenerateSalt();
var algorithm = Password.Pbkdf2Algorithm;
var password1 = new Password(passwordText, salt, algorithm);
var password2 = new Password(passwordText, salt, algorithm);
// Act & Assert
Assert.AreEqual(password1, password2);
Assert.IsTrue(password1 == password2);
}
[Test]
public void PasswordEquality_DifferentPasswords_AreNotEqual()
{
// Arrange
var salt = GenerateSalt();
var algorithm = new Pbkdf2Algorithm();
var password1 = new Password("passwordOne", salt, algorithm);
var password2 = new Password("passwordTwo", salt, algorithm);
// Act & Assert
Assert.AreNotEqual(password1, password2);
Assert.IsTrue(password1 != password2);
}
[Test]
public void PasswordEquality_DifferentSalts_AreNotEqual()
{
// Arrange
var passwordText = "mySecurePassword";
var salt1 = GenerateSalt();
var salt2 = GenerateSalt();
var algorithm = Password.Pbkdf2Algorithm;
var password1 = new Password(passwordText, salt1, algorithm);
var password2 = new Password(passwordText, salt2, algorithm);
// Act & Assert
Assert.AreNotEqual(password1, password2);
Assert.IsTrue(password1 != password2);
}
[Test]
public void ToString_ReturnsCorrectFormat()
{
// Arrange
var passwordText = "mySecurePassword";
var salt = GenerateSalt();
var algorithm = Password.Pbkdf2Algorithm;
var password = new Password(passwordText, salt, algorithm);
// Act
var result = password.ToString();
// Assert
Assert.IsTrue(result.Contains("Hash:"));
Assert.IsTrue(result.Contains("Salt:"));
Assert.IsTrue(result.Contains("Algorithm: Pbkdf2"));
}
[Test]
public void PasswordCreation_WithInvalidSalt_ReturnsEmptyHash()
{
// Arrange
var passwordText = "mySecurePassword";
byte[] invalidSalt = null; // Invalid salt
var algorithm = new Pbkdf2Algorithm();
// Act
var password = new Password(passwordText, invalidSalt, algorithm);
// Assert
Assert.IsNotNull(password.Hash);
Assert.IsEmpty(password.Hash);
}
}
}
}

66
Tests/StringExtensions.cs Normal file
View file

@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System;
using CapyKit.Extensions;
using NUnit.Framework;
namespace Tests
{
[TestFixture]
internal class StringExtensions
{
private const string Replacement = "Replaced";
[SetUp]
public void Setup()
{
// No setup required for this test fixture.
}
#region IfNullOrEmpty
[TestCase("")]
public void IfNullOrEmpty_ShouldReturnReplacementWhenValueIsNullOrEmpty(string value)
{
var result = value.IfNullOrEmpty(Replacement);
Assert.AreEqual(Replacement, result);
}
[TestCase("Not Empty")]
[TestCase(" ")] // Whitespace is not considered empty
public void IfNullOrEmpty_ShouldReturnOriginalStringWhenValueIsNotNullNorEmpty(string value)
{
var result = value.IfNullOrEmpty(Replacement);
Assert.AreEqual(value, result);
}
#endregion
#region IfNullOrWhiteSpace
[TestCase("")]
[TestCase(" ")] // Whitespace is considered empty
public void IfNullOrWhiteSpace_ShouldReturnReplacementWhenValueIsNullOrWhitespace(string value)
{
var result = value.IfNullOrWhiteSpace(Replacement);
Assert.AreEqual(Replacement, result);
}
[TestCase("Not Empty")]
[TestCase("\tTab")] // Non-whitespace character is not considered empty
public void IfNullOrWhiteSpace_ShouldReturnOriginalStringWhenValueIsNotNullNorWhitespace(string value)
{
var result = value.IfNullOrWhiteSpace(Replacement);
Assert.AreEqual(value, result);
}
#endregion
}
}

28
Tests/Tests.csproj Normal file
View file

@ -0,0 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CapyKit\CapyKit.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>
</Project>