Two XML Result passes an NUnit

217 views Asked by At

I have two xml result i need to find them whether they are correct or not.

Code :

[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);
}

I don't want to compare the result.equal(output). as both result and output are xml document . I would like to know if i could compare these two xml (Result and output ) are same or not.

1

There are 1 answers

0
Karthik On BEST ANSWER

You would have to build your own parsing and validating mechanism for this or use the utility as shared in this answer, which is similar to your query: Check if two XML files are the same in C#?