I have some tests that check strings that are displayed to the user.
I don’t wish the test to fail to due to changes in the indentations or line breaks etc. So I am
You can also use the following custom function
public static string ExceptChars(this string str, IEnumerable toExclude)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < str.Length; i++)
{
char c = str[i];
if (!toExclude.Contains(c))
sb.Append(c);
}
return sb.ToString();
}
public static bool SpaceInsenstiveComparision(this string stringa, string stringb)
{
return stringa.ExceptChars(new[] { ' ', '\t', '\n', '\r' }).Equals(stringb.ExceptChars(new[] { ' ', '\t', '\n', '\r' }));
}
And then use it following way
"Te st".SpaceInsenstiveComparision("Te st");