public void EndWithTheseTest_CollectionString() { Assert.False(StringJudgment.EndWithThese("0", new List <string> { "1", "2" })); Assert.False(StringJudgment.EndWithThese("123", new List <string> { "", "" })); Assert.False(StringJudgment.EndWithThese("1234", new List <string> { "123", "23" })); Assert.False(StringJudgment.EndWithThese("23", new List <string> { "234", "2" })); Assert.False(StringJudgment.EndWithThese("123", new List <string> { null, null })); Assert.False(StringJudgment.EndWithThese("", new List <string> { "", "" })); Assert.False(StringJudgment.EndWithThese("", new List <string> { null, null })); Assert.False(StringJudgment.EndWithThese(null, new List <string> { "", "" })); Assert.False(StringJudgment.EndWithThese(null, new List <string> { null, null })); Assert.False(StringJudgment.EndWithThese(null, new List <string> { "", null })); Assert.False(StringJudgment.EndWithThese("", new List <string> { "", null })); Assert.True(StringJudgment.EndWithThese("1234", new List <string> { "1", "12", "123", "234", "34", "4" })); Assert.True(StringJudgment.EndWithThese("1234", new List <string> { "1234", "234", "12", "1" })); List <string> nullList = new List <string>(); nullList = null; Assert.False(StringJudgment.EndWithThese("", nullList)); }
public void EndWithTheseTest_SingleString() { Assert.False(StringJudgment.EndWithThese("0", "1")); Assert.False(StringJudgment.EndWithThese("123", "")); Assert.False(StringJudgment.EndWithThese("1234", "123")); Assert.False(StringJudgment.EndWithThese("23", "234")); Assert.False(StringJudgment.EndWithThese("123", null)); Assert.False(StringJudgment.EndWithThese("", null)); Assert.False(StringJudgment.EndWithThese(null, "")); Assert.False(StringJudgment.EndWithThese(null, null)); Assert.False(StringJudgment.EndWithThese("", "")); Assert.True(StringJudgment.EndWithThese("1234", "4")); Assert.True(StringJudgment.EndWithThese("1234", "1234")); Assert.True(StringJudgment.EndWithThese("12345678", "5678")); }
public void EndWithTheseTest_MutliStrings() { Assert.False(StringJudgment.EndWithThese("0", "1", "2")); Assert.False(StringJudgment.EndWithThese("123", "", "")); Assert.False(StringJudgment.EndWithThese("1234", "123", "23")); Assert.False(StringJudgment.EndWithThese("23", "234", "2")); Assert.False(StringJudgment.EndWithThese("123", null, null)); Assert.False(StringJudgment.EndWithThese("", "", "")); Assert.False(StringJudgment.EndWithThese("", null, null)); Assert.False(StringJudgment.EndWithThese(null, "", "")); Assert.False(StringJudgment.EndWithThese(null, null, null)); Assert.False(StringJudgment.EndWithThese(null, "", null)); Assert.False(StringJudgment.EndWithThese("", "", null)); Assert.True(StringJudgment.EndWithThese("1234", "1", "12", "123", "234", "34", "4")); Assert.True(StringJudgment.EndWithThese("1234", "1234", "234", "12", "1")); }
/// <summary> /// 确定此字符串实例的结尾是否与指定的字符串数组中的某一个成员匹配。 /// <para>只要有一个匹配,则返回 True,不然则返回 False</para> /// </summary> /// <param name="string"></param> /// <param name="values"></param> /// <returns></returns> public static bool EndsWith(this string @string, ICollection <string> values) => StringJudgment.EndWithThese(@string, values);
/// <summary> /// 确定此字符串实例的结尾是否与指定的字符串数组中的某一个成员匹配。 /// <para>只要有一个匹配,则返回 True,不然则返回 False</para> /// </summary> /// <param name="string"></param> /// <param name="values"></param> /// <returns></returns> public static bool EndsWith(this string @string, params string[] values) => StringJudgment.EndWithThese(@string, values);