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