-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(testing): add unit test to project
- Loading branch information
1 parent
312610e
commit c3f0622
Showing
4 changed files
with
75 additions
and
0 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Unit_testing | ||
{ | ||
public class Tests | ||
{ | ||
private string _pattern; | ||
|
||
[SetUp] | ||
public void Setup() | ||
{ | ||
_pattern = @"^[A-Za-zÀ-ž&@£$€¥(){}\[\]<>!«»“”'‘’?""/*=#%+0-9.,:;\\/-]+$"; | ||
} | ||
|
||
[Test] | ||
[TestCase("ValidName123", true)] | ||
[TestCase("NameWithAccentsÀÁÂ", true)] | ||
[TestCase("NameWithSymbols&@£$€¥", true)] | ||
[TestCase("NameWithPunctuation.,:;-", true)] | ||
[TestCase("NameWithBrackets()", true)] | ||
[TestCase("NameWithBrackets[]", true)] | ||
[TestCase("NameWithBrackets{}", true)] | ||
[TestCase("NameWithBrackets<>", true)] | ||
[TestCase("NameWithExclamation!", true)] | ||
[TestCase("NameWithGuillemet«»", true)] | ||
[TestCase("NameWithInvertedComma“”", true)] | ||
[TestCase("NameWithApostrophe‘’", true)] | ||
[TestCase("NameWithQuestionMark?", true)] | ||
[TestCase("NameWithSolidus\\/\\", true)] | ||
[TestCase("NameWithSigns*=", true)] | ||
[TestCase("NameWithSymbols#%+", true)] | ||
public void TestAcceptedCharacters(string input, bool expectedIsValid) | ||
{ | ||
var isValid = Regex.IsMatch(input, _pattern); | ||
Assert.AreEqual(expectedIsValid, isValid); | ||
} | ||
} | ||
} | ||
|
||
|
||
|
||
|
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,25 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<RootNamespace>Unit_testing</RootNamespace> | ||
<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> | ||
<Using Include="NUnit.Framework" /> | ||
</ItemGroup> | ||
|
||
</Project> |