EndsWithConstraint
EndsWithConstraint can test whether a string ends
with an expected substring.
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class EndsWithConstraint : StringConstraint
{
public EndsWithConstraint(string expected)
: base(expected)
{
descriptionText = "String ending with";
}
protected override bool Matches(string actual)
{
StringComparison comparisonType = caseInsensitive ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture;
return actual?.EndsWith(expected, comparisonType) ?? false;
}
}
}