I have the following strings:
Actual | Expected
"The Actual String" | "The"
| "Actual"
| "String"
| "Other string"
| ...
I need to create a method that will Assert that any of the Expected strings is contained in the actual string, something like this:
[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)
{
}
}
I tried the CollectionAssert.Contains method but it didn’t work. Is there a quick method I can use without iterating into the expected strings?
It returns true if all the values of expected array is found in actual variable:
Return true even if just one value is contained in the actual string: