0

我有两个 xml 结果,无论它们是否正确,我都需要找到它们。

代码 :

[TestCase]
    public void InterrogateChangeInCircumstances()
    {
        // Accepting the input as well as the output
        string test = inputInterrogateChangeInCircumstances();
        string output = outputInterrogateChangeInCircumstances();
    //Web Service is getting called.
    var request = (HttpWebRequest)WebRequest.Create(ConfigurationManager.AppSettings["request_url"]);
    request.Method = "POST";
    var result = Utils.ProcessRequest(request, test);

    //Determing whether the response is passed or failed.
    result = result.Replace(Environment.NewLine, "").Replace(" ", "");
    output = output.Replace(Environment.NewLine, "").Replace(" ", "");


    if (result.Equals(output))
        Assert.Pass();
    else
        Assert.Fail("result: {0} original: {1}", result, output);
}

我不想比较 result.equal(output)。因为结果和输出都是 xml 文档。我想知道我是否可以比较这两个 xml(结果和输出)是否相同。

4

1 回答 1

1

您必须为此构建自己的解析和验证机制,或者使用此答案中共享的实用程序,这与您的查询类似: 检查两个 XML 文件在 C# 中是否相同?

于 2015-03-26T22:21:05.337 回答