我有以下字符串:
Actual | Expected
"The Actual String" | "The"
| "Actual"
| "String"
| "Other string"
| ...
我需要创建一个方法,将Assert
任何Expected
字符串包含在实际字符串中,如下所示:
[TestClass]
public class UnitTest
{
[TestMethod]
public void TestMethod()
{
//Assertion Passed
AssertContainsString("The Actual String", "The");
//Assertion Passed
AssertContainsString("The Actual String", "Something", "Actual");
//Assertion Failed
AssertContainsString("The Actual String", "Something", "Something Else");
}
public void AssertContainsString(string actual, params string[] expected)
{
}
}
我尝试了该CollectionAssert.Contains
方法,但没有奏效。有没有一种快速的方法可以在不迭代expected
字符串的情况下使用?