PrefixConstraint
Abstract base class used for prefixes
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints
{
[NullableContext(1)]
[Nullable(0)]
public abstract class PrefixConstraint : Constraint
{
protected IConstraint BaseConstraint { get; }
protected string DescriptionPrefix { get; }
public override string Description => FormatDescription(DescriptionPrefix, BaseConstraint);
protected PrefixConstraint(IResolveConstraint baseConstraint, string descriptionPrefix)
: base(baseConstraint)
{
Guard.ArgumentNotNull(baseConstraint, "baseConstraint");
BaseConstraint = baseConstraint.Resolve();
DescriptionPrefix = descriptionPrefix;
}
internal static string FormatDescription(string descriptionPrefix, IConstraint baseConstraint)
{
bool flag = (baseConstraint is EqualConstraint || baseConstraint is EqualStringConstraint) ? true : false;
bool flag2 = flag;
if (!flag2) {
Type type = baseConstraint.GetType();
flag2 = (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(EqualNumericConstraint<>));
}
return string.Format(flag2 ? "{0} equal to {1}" : "{0} {1}", descriptionPrefix, baseConstraint.Description);
}
}
}