本文整理汇总了C#中System.StringComparison.GetComparer方法的典型用法代码示例。如果您正苦于以下问题:C# StringComparison.GetComparer方法的具体用法?C# StringComparison.GetComparer怎么用?C# StringComparison.GetComparer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.StringComparison
的用法示例。
在下文中一共展示了StringComparison.GetComparer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldNotStartWith
public static void ShouldNotStartWith(this string actual, string begining, StringComparison comparisonType = StringComparison.CurrentCulture)
{
if (actual.Length < begining.Length) {
return;
}
string temp = actual.Substring(0, begining.Length);
Assert.NotEqual(begining, temp, comparisonType.GetComparer());
}
示例2: ShouldEndWith
/// <summary>
/// Verifies that a string ends with a given sub-string, using the given comparison type.
/// </summary>
/// <param name="actual">The actual.</param>
/// <param name="ending">The expected end.</param>
/// <param name="stringComparison">The string comparison.</param>
/// <remarks></remarks>
public static void ShouldEndWith(this string actual, string ending, StringComparison stringComparison = StringComparison.CurrentCulture)
{
if (actual.Length < ending.Length) {
throw new EqualException(ending, actual);
}
string temp = actual.Substring(actual.Length - ending.Length);
Assert.Equal(ending, temp, stringComparison.GetComparer());
}
示例3: ShouldEqual
/// <summary>
/// Verifies that a string equals a given string, using the given comparison type.
/// </summary>
/// <param name="actual">The actual.</param>
/// <param name="expected">The expected.</param>
/// <param name="comparisonType">Type of the comparison.</param>
/// <remarks></remarks>
public static void ShouldEqual(this string actual,
string expected,
StringComparison comparisonType = StringComparison.CurrentCulture)
{
Assert.Equal(expected, actual, comparisonType.GetComparer());
}
示例4: ShouldStartWith
/// <summary>
/// Verifies that a string starts with a given sub-string, using the given comparison type.
/// </summary>
/// <param name="actual">The actual.</param>
/// <param name="begining">The expected start.</param>
/// <param name="comparisonType">The string comparison.</param>
/// <remarks></remarks>
public static void ShouldStartWith(this string actual,
string begining,
StringComparison comparisonType = StringComparison.CurrentCulture)
{
if (actual.Length < begining.Length)
{
throw new EqualException(begining, actual);
}
string temp = actual.Substring(0, begining.Length);
Assert.Equal(begining, temp, comparisonType.GetComparer());
}