/// <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()); }
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()); }
/// <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()); }
/// <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()); }