Reputation: 6442
I have some code that makes requests and compares with expected values. But I have problem comparing the string from the website with the string in the code. My unit test code says:
Assert.AreEqual failed.
Expected: <DEVOLUÇÃO DE VALORES>.
Actual: <DEVOLUÇÃO DE VALORES>.
What can I do to compare the values regadless of the character encoding?
Upvotes: 2
Views: 2658
Reputation: 6442
I just needed to use Normalize
method:
Assert.AreEqual(expected.Normalize(), actual.Normalize());
Note taht Normalize
allows you to provide the normalization form. If you do it, you have to use the same form in both strings.
Upvotes: 1
Reputation: 162
Ignore the culture information and do the comparison. Use String.ToUpperInvariant() for the strings and compare it.
Upvotes: 0