Skip to content

Commit

Permalink
#28: Synergy.Contracts: Added Fail.IfWhitespace(text) method
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcinCelej committed Feb 3, 2024
1 parent b8cad60 commit 9e7380e
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
) : void [AssertionMethod, ContractAnnotation]
- Fail.IfWhitespace(
value: string [CanBeNull, AssertionCondition],
name: string [NotNull, NotNull]
name: string? [Nullable, CallerArgumentExpression, Optional]
) : void [AssertionMethod, ContractAnnotation]
- Fail.NotNull<T>(
value: T? [CanBeNull, AssertionCondition, NoEnumeration],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
) : void [AssertionMethod, ContractAnnotation]
- Fail.IfWhitespace(
value: string [CanBeNull, AssertionCondition],
name: string [NotNull, NotNull]
name: string? [Nullable, CallerArgumentExpression, Optional]
) : void [AssertionMethod, ContractAnnotation]
- Fail.NotNull<T>(
value: T? [CanBeNull, AssertionCondition, NoEnumeration],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@
) : void [AssertionMethod, ContractAnnotation]
- Fail.IfWhitespace(
value: string [CanBeNull, AssertionCondition],
name: string [NotNull, NotNull]
name: string? [Nullable, CallerArgumentExpression, Optional]
) : void [AssertionMethod, ContractAnnotation]
- Fail.NotNull<T>(
value: T? [CanBeNull, AssertionCondition, NoEnumeration],
Expand Down
Binary file modified Contracts/Synergy.Contracts.Test/Failures/FailStringTest.cs
Binary file not shown.
12 changes: 9 additions & 3 deletions Contracts/Synergy.Contracts/Failures/FailString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,15 @@ string name
[AssertionMethod]
[ContractAnnotation("value: null => halt")]
public static void IfWhitespace(
[CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)] string value,
[NotNull] [System.Diagnostics.CodeAnalysis.NotNull] string name
)
[CanBeNull, AssertionCondition(AssertionConditionType.IS_NOT_NULL)]
string value,
#if NET6_0_OR_GREATER
[System.Runtime.CompilerServices.CallerArgumentExpression("value")]
string? name = null
#else
string name
#endif
)
{
Fail.RequiresArgumentName(name);
Fail.IfWhitespace(value, Violation.WhenWhitespace(name));
Expand Down
2 changes: 1 addition & 1 deletion Web/Synergy.Web.Api.Testing/TestServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected virtual HttpRequestMessage CreateHttpRequest(

private Uri PrepareRequestUri(string path, object? parameterToGet = null)
{
Fail.IfWhitespace(path, nameof(path));
Fail.IfWhitespace(path);

var uriBuilder = new UriBuilder
{
Expand Down

0 comments on commit 9e7380e

Please sign in to comment.