-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#86 rename test class to share project and test check content
- Loading branch information
1 parent
2e869a9
commit 228d437
Showing
3 changed files
with
125 additions
and
42 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
This file was deleted.
Oops, something went wrong.
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,125 @@ | ||
using System; | ||
using System.IO; | ||
using CryptoNet.Share; | ||
using CryptoNet.Share.Extensions; | ||
using NUnit.Framework; | ||
using Shouldly; | ||
|
||
namespace CryptoNet.UnitTests | ||
{ | ||
[TestFixture] | ||
public class ShareProjectTests | ||
{ | ||
[Test] | ||
public void TryGetSolutionDirectoryInfo_ShouldReturnNull_WhenNoSolutionFileExists() | ||
{ | ||
// Act | ||
var result = DirectoryExension.TryGetSolutionDirectoryInfo(); | ||
|
||
// Assert | ||
result.ShouldNotBeNull(); | ||
result!.FullName.ShouldContain("CryptoNet"); | ||
} | ||
|
||
[Test] | ||
public void TryGetSolutionDirectoryInfo_ShouldReturnDirectoryWithTestFiles() | ||
{ | ||
// Arrange | ||
string solutionFilePath = Path.Combine(Common.TestFilesPath); | ||
|
||
// Act | ||
var result = DirectoryExension.TryGetSolutionDirectoryInfo(); | ||
var testFiles = Path.Combine(result!.FullName, "Resources", "TestFiles"); | ||
var di = new DirectoryInfo(testFiles); | ||
var files = di.GetFiles("test.*"); | ||
|
||
// Assert | ||
files.ShouldNotBeNull(); | ||
files.Count().ShouldBe(4); | ||
Check failure on line 38 in CryptoNet.UnitTests/ShareProjectTests.cs GitHub Actions / build
Check failure on line 38 in CryptoNet.UnitTests/ShareProjectTests.cs GitHub Actions / build
Check failure on line 38 in CryptoNet.UnitTests/ShareProjectTests.cs GitHub Actions / build (ubuntu-latest)
|
||
} | ||
|
||
[Test] | ||
public void CheckContent_WhenContentsAreSame_ShouldReturnTrue() | ||
{ | ||
// Arrange | ||
string originalContent = "This is a test string"; | ||
string decryptedContent = "This is a test string"; | ||
|
||
// Act | ||
bool result = Common.CheckContent(originalContent, decryptedContent); | ||
|
||
// Assert | ||
result.ShouldBeTrue("because both contents are identical, so MD5 hashes should match."); | ||
} | ||
|
||
[Test] | ||
public void CheckContent_WhenContentsAreDifferent_ShouldReturnFalse() | ||
{ | ||
// Arrange | ||
string originalContent = "This is a test string"; | ||
string decryptedContent = "This is a different string"; | ||
|
||
// Act | ||
bool result = Common.CheckContent(originalContent, decryptedContent); | ||
|
||
// Assert | ||
result.ShouldBeFalse("because contents are different, so their MD5 hashes should not match."); | ||
} | ||
|
||
[Test] | ||
public void CheckContent_WhenBothContentsAreEmpty_ShouldReturnTrue() | ||
{ | ||
// Arrange | ||
string originalContent = ""; | ||
string decryptedContent = ""; | ||
|
||
// Act | ||
bool result = Common.CheckContent(originalContent, decryptedContent); | ||
|
||
// Assert | ||
result.ShouldBeTrue("because both contents are empty, and their MD5 hashes should match."); | ||
} | ||
|
||
[Test] | ||
public void CheckContent_WhenOneContentIsNull_ShouldReturnFalse() | ||
{ | ||
// Arrange | ||
string originalContent = "This is a test string"; | ||
string? decryptedContent = null; | ||
|
||
// Act | ||
bool result = Common.CheckContent(originalContent, decryptedContent!); | ||
|
||
// Assert | ||
result.ShouldBeFalse("because one content is null, so their MD5 hashes cannot match."); | ||
} | ||
|
||
[Test] | ||
public void CheckContent_WhenBothContentsAreNull_ShouldReturnTrue() | ||
{ | ||
// Arrange | ||
string? originalContent = null; | ||
string? decryptedContent = null; | ||
|
||
// Act | ||
bool result = Common.CheckContent(originalContent!, decryptedContent!); | ||
|
||
// Assert | ||
result.ShouldBeTrue("because both contents are null, so their MD5 hashes should be the same."); | ||
} | ||
|
||
[Test] | ||
public void CheckContent_WhenContentsContainSpecialCharacters_ShouldReturnTrue() | ||
{ | ||
// Arrange | ||
string originalContent = "!@#$%^&*()_+1234567890"; | ||
string decryptedContent = "!@#$%^&*()_+1234567890"; | ||
|
||
// Act | ||
bool result = Common.CheckContent(originalContent, decryptedContent); | ||
|
||
// Assert | ||
result.ShouldBeTrue("because both contents are identical even with special characters."); | ||
} | ||
} | ||
} |