DimonSmart.RegexUnitTester.TestAdapter
1.24602.2213
Prefix Reserved
See the version list below for details.
dotnet add package DimonSmart.RegexUnitTester.TestAdapter --version 1.24602.2213
NuGet\Install-Package DimonSmart.RegexUnitTester.TestAdapter -Version 1.24602.2213
<PackageReference Include="DimonSmart.RegexUnitTester.TestAdapter" Version="1.24602.2213" />
paket add DimonSmart.RegexUnitTester.TestAdapter --version 1.24602.2213
#r "nuget: DimonSmart.RegexUnitTester.TestAdapter, 1.24602.2213"
// Install DimonSmart.RegexUnitTester.TestAdapter as a Cake Addin #addin nuget:?package=DimonSmart.RegexUnitTester.TestAdapter&version=1.24602.2213 // Install DimonSmart.RegexUnitTester.TestAdapter as a Cake Tool #tool nuget:?package=DimonSmart.RegexUnitTester.TestAdapter&version=1.24602.2213
DimonSmart.RegexUnitTester.Attributes
Overview
The DimonSmart.RegexUnitTester.Attributes
NuGet package enhances regex testing by using custom attributes to specify test cases and document regex behaviors, improving code readability and facilitating automated testing via the DimonSmart.RegexUnitTester.TestAdapter
.
Features
- ShouldMatchAttribute: Asserts that a regex should match the provided test data.
- ShouldNotMatchAttribute: Asserts that a regex should not match the provided test data, useful for patterns intended to exclude certain formats.
- InfoMatchAttribute: Captures cases that fall into a gray area, neither strictly matching nor non-matching, for logging and informational purposes without triggering errors.
Installation
To install DimonSmart.RegexUnitTester.Attributes
, run:
Install-Package DimonSmart.RegexUnitTester.Attributes
Comparison Example
Traditional Comments
// Regex "10001" matches, "ABCDE" does not match, "123 45" is logged.
public const string USZipCodeRegex = @"^\d{5}$";
Attribute Usage
[ShouldMatch("10001"), ShouldNotMatch("ABCDE"), InfoMatch("123 45")]
public const string USZipCodeRegex = @"^\d{5}$";
Detailed Attribute Usage Example
using System.Text.RegularExpressions;
using DimonSmart.RegexUnitTester.Attributes;
namespace PostalCodeValidation
{
public class PostalCodeRegexTests
{
[ShouldMatch("10001"), ShouldNotMatch("ABCDE"), InfoMatch("123 45")]
public const string USZipCodeRegex = @"^\d{5}$";
[ShouldMatch("A1A 1A1"), ShouldNotMatch("12345"), InfoMatch("A1A-1A1")]
public const string CanadaPostalCodeRegex = @"^[A-Z]\d[A-Z] \d[A-Z]\d$";
}
}
Key Scenarios
- ShouldMatch: "10001" correctly matches the US postal code format.
- ShouldNotMatch: "ABCDE" fails to match as it's not a valid postal code format.
- InfoMatch: "123 45" represents a borderline case which is logged for potential reevaluation but does not trigger a test failure.
Integration with DimonSmart.RegexUnitTester.TestAdapter
For automated testing, pair this package with DimonSmart.RegexUnitTester.TestAdapter
:
Install-Package DimonSmart.RegexUnitTester.TestAdapter
This streamlined approach using attributes not only facilitates easier unit testing but also improves documentation directly within the code, maintaining clarity and efficiency.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- DimonSmart.RegexUnitTester.Attributes (>= 1.24602.2213)
- Microsoft.Testing.Extensions.VSTestBridge (>= 1.1.0)
- Microsoft.TestPlatform.AdapterUtilities (>= 17.9.0)
- Microsoft.TestPlatform.ObjectModel (>= 17.9.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.24607.2005 | 104 | 6/7/2024 |
1.24605.2215 | 108 | 6/5/2024 |
1.24602.2213 | 108 | 6/2/2024 |
1.0.3 | 93 | 5/14/2024 |
1.0.0.2 | 101 | 5/9/2024 |
1.0.0 | 133 | 5/5/2024 |