-
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
074f34a
commit 264e346
Showing
23 changed files
with
401 additions
and
135 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
10 changes: 10 additions & 0 deletions
10
...aticSettingsTests/VerifyCombinationsTests.BuildAddressExceptionsDisabledTest.verified.txt
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,10 @@ | ||
{ | ||
1, Smith St , Sydney : 1 Smith St, Sydney, | ||
1, Smith St , Chicago: 1 Smith St, Chicago, | ||
1, Wallace St, Sydney : 1 Wallace St, Sydney, | ||
1, Wallace St, Chicago: 1 Wallace St, Chicago, | ||
10, Smith St , Sydney : 10 Smith St, Sydney, | ||
10, Smith St , Chicago: 10 Smith St, Chicago, | ||
10, Wallace St, Sydney : 10 Wallace St, Sydney, | ||
10, Wallace St, Chicago: 10 Wallace St, Chicago | ||
} |
5 changes: 5 additions & 0 deletions
5
src/StaticSettingsTests/VerifyCombinationsTests.Defaults.verified.txt
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,5 @@ | ||
{ | ||
A: a, | ||
b: b, | ||
C: c | ||
} |
5 changes: 5 additions & 0 deletions
5
src/StaticSettingsTests/VerifyCombinationsTests.WithCaptureExceptions.verified.txt
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,5 @@ | ||
{ | ||
A: a, | ||
b: ArgumentException: B is not allowed, | ||
C: c | ||
} |
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,85 @@ | ||
#pragma warning disable VerifyCombinations | ||
public class VerifyCombinationsTests | ||
{ | ||
#region GlobalCaptureExceptions | ||
|
||
[ModuleInitializer] | ||
public static void Initialize() => | ||
VerifyCombinationSettings.CaptureExceptions(); | ||
|
||
#endregion | ||
|
||
[Fact] | ||
public Task Defaults() | ||
{ | ||
string[] list = ["A", "b", "C"]; | ||
return VerifyCombinations( | ||
_ => _.ToLower(), | ||
list); | ||
} | ||
|
||
[Fact] | ||
public Task WithCaptureExceptions() | ||
{ | ||
string[] a = ["A", "b", "C"]; | ||
return VerifyCombinations( | ||
a => | ||
{ | ||
if (a == "b") | ||
{ | ||
throw new ArgumentException("B is not allowed"); | ||
} | ||
|
||
return a.ToLower(); | ||
}, | ||
a, | ||
captureExceptions: true); | ||
} | ||
|
||
[Fact] | ||
public Task WithNoCaptureExceptions() | ||
{ | ||
string[] a = ["A", "b", "C"]; | ||
return Assert.ThrowsAsync<ArgumentException>(() => | ||
{ | ||
return VerifyCombinations( | ||
a => | ||
{ | ||
if (a == "b") | ||
{ | ||
throw new ArgumentException("B is not allowed"); | ||
} | ||
|
||
return a.ToLower(); | ||
}, | ||
a, | ||
captureExceptions: false); | ||
}); | ||
} | ||
public static string BuildAddress(int streetNumber, string street, string city) | ||
{ | ||
ArgumentException.ThrowIfNullOrWhiteSpace(street); | ||
ArgumentException.ThrowIfNullOrWhiteSpace(city); | ||
ArgumentOutOfRangeException.ThrowIfLessThan(streetNumber, 1); | ||
|
||
return $"{streetNumber} {street}, {city}"; | ||
} | ||
|
||
#region CombinationSample_CaptureExceptionsFalse | ||
|
||
[Fact] | ||
public Task BuildAddressExceptionsDisabledTest() | ||
{ | ||
int[] streetNumbers = [1, 10]; | ||
string[] streets = ["Smith St", "Wallace St"]; | ||
string[] cities = ["Sydney", "Chicago"]; | ||
return VerifyCombinations( | ||
BuildAddress, | ||
streetNumbers, | ||
streets, | ||
cities, | ||
captureExceptions: false); | ||
} | ||
|
||
#endregion | ||
} |
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
Oops, something went wrong.