vendredi 29 juillet 2016

.NET Webhandler Test string equality comparison fails

I am currently writing tests for my .NET application. To test a webhandler, I am calling it with a webclient and am planning to compare it with a string coming from a file, which I previously have written.

I am storing the expected string in a file, because the WebHandler is generating a html-document, which I am returning as text/plain.

This is the code I am using currently:

private string getWebResponse(string projectName)
{
    string url = "http://ift.tt/2aOScw9}";
    WebClient client = new WebClient();
    return client.DownloadString(string.Format(url, projectName));
}

[TestMethod()]
public void ProcessRequestTest1()
{
    string expected = File.ReadAllText(Path.Combine(projectRootFolder, "testresults", "Test (1).txt"), Encoding.UTF8);
    Assert.AreEqual(expected, getWebResponse("Test (1)"));
}

When running this testcase, the test fails even though the strings returned appear to be identical (as I have tested both of them with a diff-tool). Is there an issue that I am missing when gathering the strings?

Aucun commentaire:

Enregistrer un commentaire