ConstraintExtensions
using NUnit.Framework.Constraints;
using System;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace NUnit.Framework.Internal.Extensions
{
internal static class ConstraintExtensions
{
[NullableContext(1)]
public static Task<ConstraintResult> ApplyToAsync<[Nullable(2)] TActual>(this IConstraint constraint, Func<Task<TActual>> delTask)
{
IAsyncConstraint asyncConstraint = constraint as IAsyncConstraint;
if (asyncConstraint == null)
throw new NotSupportedException("Constraint " + constraint?.GetType().Name + " does not support async execution.");
return asyncConstraint.ApplyToAsync(delTask);
}
}
}