断言函数比较c#中2种不同方法返回的字符串

Assert function to compare strings returned by 2 different methods in c#

我在 c# selenium 框架中有 2 个方法。我正在使用 Nunit 框架进行测试

public String method1()

{

String s  = "This is example 1";

return s

}

public string method2()

{

String s = "example 2";

return s;

}

我需要检查两个字符串是否包含相同的特定文本 'Example'。有没有'Assert'函数可以比较?

从您的回复来看,您似乎只需要使用:

string one = method1();
string two = method2();
StringAssert.Contains(two, one);