diff --git a/Directory.Packages.props b/Directory.Packages.props
index 5859b50..5b42060 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -3,9 +3,9 @@
true
-
-
-
+
+
+
diff --git a/Source/aweXpect.Web/ThatHttpRequestMessage.HasContent.cs b/Source/aweXpect.Web/ThatHttpRequestMessage.HasContent.cs
index 38e4b89..511fd9c 100644
--- a/Source/aweXpect.Web/ThatHttpRequestMessage.HasContent.cs
+++ b/Source/aweXpect.Web/ThatHttpRequestMessage.HasContent.cs
@@ -86,7 +86,7 @@ public async Task IsMetBy(
#else
_message = await actual.Content.ReadAsStringAsync(cancellationToken);
#endif
- if (options.AreConsideredEqual(_message, expected))
+ if (await options.AreConsideredEqual(_message, expected))
{
Outcome = Outcome.Success;
return this;
diff --git a/Source/aweXpect.Web/ThatHttpResponseMessage.HasContent.cs b/Source/aweXpect.Web/ThatHttpResponseMessage.HasContent.cs
index 00e0990..3f82f5c 100644
--- a/Source/aweXpect.Web/ThatHttpResponseMessage.HasContent.cs
+++ b/Source/aweXpect.Web/ThatHttpResponseMessage.HasContent.cs
@@ -79,7 +79,7 @@ public async Task IsMetBy(
#else
_message = await actual.Content.ReadAsStringAsync(cancellationToken);
#endif
- if (options.AreConsideredEqual(_message, expected))
+ if (await options.AreConsideredEqual(_message, expected))
{
Outcome = Outcome.Success;
return this;
diff --git a/Source/aweXpect.Web/ThatHttpResponseMessage.HasContentType.cs b/Source/aweXpect.Web/ThatHttpResponseMessage.HasContentType.cs
index 8f55d88..790a35d 100644
--- a/Source/aweXpect.Web/ThatHttpResponseMessage.HasContentType.cs
+++ b/Source/aweXpect.Web/ThatHttpResponseMessage.HasContentType.cs
@@ -1,6 +1,8 @@
using System;
using System.Net.Http;
using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
using aweXpect.Core;
using aweXpect.Core.Constraints;
using aweXpect.Helpers;
@@ -39,11 +41,11 @@ private sealed class HasContentTypeConstraint(
string expected,
StringEqualityOptions options)
: ConstraintResult.WithNotNullValue(it, grammars),
- IValueConstraint
+ IAsyncConstraint
{
private string? _contentType;
- public ConstraintResult IsMetBy(HttpResponseMessage? actual)
+ public async Task IsMetBy(HttpResponseMessage? actual, CancellationToken cancellationToken)
{
Actual = actual;
if (actual == null)
@@ -59,7 +61,7 @@ public ConstraintResult IsMetBy(HttpResponseMessage? actual)
return this;
}
- if (!options.AreConsideredEqual(_contentType, expected))
+ if (!await options.AreConsideredEqual(_contentType, expected))
{
expectationBuilder.AddContext(actual);
Outcome = Outcome.Failure;
diff --git a/Source/aweXpect.Web/ThatHttpResponseMessage.HasProblemDetailsContent.cs b/Source/aweXpect.Web/ThatHttpResponseMessage.HasProblemDetailsContent.cs
index 9b4869a..36e2620 100644
--- a/Source/aweXpect.Web/ThatHttpResponseMessage.HasProblemDetailsContent.cs
+++ b/Source/aweXpect.Web/ThatHttpResponseMessage.HasProblemDetailsContent.cs
@@ -90,7 +90,7 @@ public async Task IsMetBy(
{
_failures.Add($"{It} did not match the expected format because no 'type' property existed");
}
- else if (expectedType != null && !typeOptions.AreConsideredEqual(type, expectedType))
+ else if (expectedType != null && !await typeOptions.AreConsideredEqual(type, expectedType))
{
_failures.Add(
$"{It} was type {Formatter.Format(type)} which {new StringDifference(type, expectedType)}");
@@ -101,19 +101,19 @@ public async Task IsMetBy(
_failures.Add($"{It} had status {Formatter.Format(status)}");
}
- if (!options.IsTitleConsideredEqualTo(title))
+ if (!await options.IsTitleConsideredEqualTo(title))
{
_failures.Add(
$"{It} had title {Formatter.Format(title)} which {new StringDifference(title, options.Title)}");
}
- if (!options.IsDetailConsideredEqualTo(detail))
+ if (!await options.IsDetailConsideredEqualTo(detail))
{
_failures.Add(
$"{It} had detail {Formatter.Format(detail)} which {new StringDifference(detail, options.Detail)}");
}
- if (!options.IsInstanceConsideredEqualTo(instance))
+ if (!await options.IsInstanceConsideredEqualTo(instance))
{
_failures.Add(
$"{It} had instance {Formatter.Format(instance)} which {new StringDifference(instance, options.Instance)}");
diff --git a/Source/aweXpect.Web/Web/Results/HasHeaderValueResult.cs b/Source/aweXpect.Web/Web/Results/HasHeaderValueResult.cs
index 9c8645b..e9634b7 100644
--- a/Source/aweXpect.Web/Web/Results/HasHeaderValueResult.cs
+++ b/Source/aweXpect.Web/Web/Results/HasHeaderValueResult.cs
@@ -1,5 +1,7 @@
using System;
using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
using aweXpect.Core;
using aweXpect.Core.Constraints;
using aweXpect.Options;
@@ -88,11 +90,11 @@ private sealed class WithHeaderValueConstraint(
Func headerValueAccessor,
StringEqualityOptions options)
: ConstraintResult.WithValue(grammars),
- IValueConstraint
+ IAsyncConstraint
{
private string?[]? _headerValues;
- public ConstraintResult IsMetBy(TType? actual)
+ public async Task IsMetBy(TType? actual, CancellationToken cancellationToken)
{
Actual = actual;
if (actual is null)
@@ -109,7 +111,7 @@ public ConstraintResult IsMetBy(TType? actual)
}
string? headerValue = _headerValues[0];
- Outcome = options.AreConsideredEqual(headerValue, expected) ? Outcome.Success : Outcome.Failure;
+ Outcome = await options.AreConsideredEqual(headerValue, expected) ? Outcome.Success : Outcome.Failure;
return this;
}
diff --git a/Source/aweXpect.Web/Web/Results/ProblemDetailsOptions.cs b/Source/aweXpect.Web/Web/Results/ProblemDetailsOptions.cs
index fad8aa1..ab09f98 100644
--- a/Source/aweXpect.Web/Web/Results/ProblemDetailsOptions.cs
+++ b/Source/aweXpect.Web/Web/Results/ProblemDetailsOptions.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Threading.Tasks;
using aweXpect.Options;
namespace aweXpect.Web.Results;
@@ -97,19 +98,34 @@ public StringEqualityOptions WithInstance(string instance)
///
/// Checks if the matches the expected .
///
- public bool IsTitleConsideredEqualTo(string? title)
+#if NET8_0_OR_GREATER
+ public ValueTask
+#else
+ public Task
+#endif
+ IsTitleConsideredEqualTo(string? title)
=> _titleOptions.AreConsideredEqual(title, Title);
///
/// Checks if the matches the expected .
///
- public bool IsDetailConsideredEqualTo(string? detail)
+#if NET8_0_OR_GREATER
+ public ValueTask
+#else
+ public Task
+#endif
+ IsDetailConsideredEqualTo(string? detail)
=> _detailOptions.AreConsideredEqual(detail, Detail);
///
/// Checks if the matches the expected .
///
- public bool IsInstanceConsideredEqualTo(string? instance)
+#if NET8_0_OR_GREATER
+ public ValueTask
+#else
+ public Task
+#endif
+ IsInstanceConsideredEqualTo(string? instance)
=> _instanceOptions.AreConsideredEqual(instance, Instance);
///
@@ -121,6 +137,6 @@ public override string ToString()
_ => $", {string
.Join(", ", _parts
.Take(_parts.Count - 1)
- .Select(part => part.Invoke()))} and {_parts[^1].Invoke()}",
+ .Select(part => part.Invoke()))} and {_parts[^1].Invoke()}"
};
}
diff --git a/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_net8.0.txt b/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_net8.0.txt
index e3b03eb..9106d06 100644
--- a/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_net8.0.txt
+++ b/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_net8.0.txt
@@ -64,9 +64,9 @@ namespace aweXpect.Web.Results
public string? Instance { get; }
public int? Status { get; }
public string? Title { get; }
- public bool IsDetailConsideredEqualTo(string? detail) { }
- public bool IsInstanceConsideredEqualTo(string? instance) { }
- public bool IsTitleConsideredEqualTo(string? title) { }
+ public System.Threading.Tasks.ValueTask IsDetailConsideredEqualTo(string? detail) { }
+ public System.Threading.Tasks.ValueTask IsInstanceConsideredEqualTo(string? instance) { }
+ public System.Threading.Tasks.ValueTask IsTitleConsideredEqualTo(string? title) { }
public override string ToString() { }
public aweXpect.Options.StringEqualityOptions WithDetail(string detail) { }
public aweXpect.Options.StringEqualityOptions WithInstance(string instance) { }
diff --git a/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_netstandard2.0.txt b/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_netstandard2.0.txt
index 24c40b6..bee5b18 100644
--- a/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_netstandard2.0.txt
+++ b/Tests/aweXpect.Web.Api.Tests/Expected/aweXpect.Web_netstandard2.0.txt
@@ -64,9 +64,9 @@ namespace aweXpect.Web.Results
public string? Instance { get; }
public int? Status { get; }
public string? Title { get; }
- public bool IsDetailConsideredEqualTo(string? detail) { }
- public bool IsInstanceConsideredEqualTo(string? instance) { }
- public bool IsTitleConsideredEqualTo(string? title) { }
+ public System.Threading.Tasks.Task IsDetailConsideredEqualTo(string? detail) { }
+ public System.Threading.Tasks.Task IsInstanceConsideredEqualTo(string? instance) { }
+ public System.Threading.Tasks.Task IsTitleConsideredEqualTo(string? title) { }
public override string ToString() { }
public aweXpect.Options.StringEqualityOptions WithDetail(string detail) { }
public aweXpect.Options.StringEqualityOptions WithInstance(string instance) { }