-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert parameterized tests to use ArgumentConstraintTestCases
- Loading branch information
1 parent
0d95f00
commit 319f26a
Showing
6 changed files
with
182 additions
and
162 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
41 changes: 41 additions & 0 deletions
41
tests/FakeItEasy.Analyzer.Tests.Shared/Helpers/ArgumentConstraintTestCases.cs
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,41 @@ | ||
namespace FakeItEasy.Analyzer.Tests.Helpers | ||
{ | ||
using System; | ||
using Xunit; | ||
|
||
public static class ArgumentConstraintTestCases | ||
{ | ||
/// <summary> | ||
/// Create test cases from the given argument constraints. | ||
/// </summary> | ||
/// <param newm="constraints"> | ||
/// List of constraints to use as a seed. Each constraint must use the "A" | ||
/// argument constraint-building entry point. Test cases using "An" will | ||
/// be built to augment these. | ||
/// </param> | ||
public static TheoryData<string> From(params string[] constraints) | ||
{ | ||
var theoryData = new TheoryData<string>(); | ||
foreach (var constraint in constraints) | ||
{ | ||
ValidateConstraint(constraint); | ||
|
||
theoryData.Add(constraint); | ||
} | ||
|
||
return theoryData; | ||
} | ||
|
||
private static void ValidateConstraint(string constraint) | ||
{ | ||
if (constraint.Length < 2 || | ||
constraint[0] != 'A' || | ||
(constraint[1] != '<' && constraint[1] != '(')) | ||
{ | ||
throw new ArgumentException( | ||
$"Constraint '{constraint}' is not an argument constraint built using the 'A' entry point.", | ||
nameof(constraint)); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.