Skip to content

Commit

Permalink
#86 test UniqueKeyGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
maythamfahmi committed Oct 20, 2024
1 parent a86321b commit d11e761
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions CryptoNet.UnitTests/ShareProjectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,48 @@ public void CheckContent_WhenContentsContainSpecialCharacters_ShouldReturnTrue()
// Assert
result.ShouldBeTrue("because both contents are identical even with special characters.");
}

[Test]
public void UniqueKeyGenerator_ShouldGenerateCorrectHash_ForGivenInput()
{
// Arrange
string input = "testInput";
string expectedHash = "FB054EFB1303ABDFD6E954E83F41E7BD"; // Pre-calculated MD5 hash for "testInput"

// Act
string result = Common.UniqueKeyGenerator(input);

// Assert
result.ShouldBe(expectedHash, "The MD5 hash generated by UniqueKeyGenerator is incorrect.");
}

[Test]
public void UniqueKeyGenerator_ShouldGenerateSameHash_ForSameInput()
{
// Arrange
string input = "sameInput";

// Act
string result1 = Common.UniqueKeyGenerator(input);
string result2 = Common.UniqueKeyGenerator(input);

// Assert
result1.ShouldBe(result2, "UniqueKeyGenerator should return the same hash for the same input.");
}

[Test]
public void UniqueKeyGenerator_ShouldGenerateDifferentHash_ForDifferentInputs()
{
// Arrange
string input1 = "input1";
string input2 = "input2";

// Act
string result1 = Common.UniqueKeyGenerator(input1);
string result2 = Common.UniqueKeyGenerator(input2);

// Assert
result1.ShouldNotBe(result2, "UniqueKeyGenerator should return different hashes for different inputs.");
}
}
}

0 comments on commit d11e761

Please sign in to comment.