Add tests for StringNoWhiteSpaceEqualityComparerTests
MODIFY
WalletWasabi.Tests/Helpers/StringNoWhiteSpaceEqualityComparer.cs
WalletWasabi.Tests/Helpers/StringNoWhiteSpaceEqualityComparer.cs
@@ -2,7 +2,6 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
-using System.Text;
namespace WalletWasabi.Tests.Helpers
{
@@ -10,6 +9,11 @@ namespace WalletWasabi.Tests.Helpers
{
public bool Equals([AllowNull] string x, [AllowNull] string y)
{
+ if (x == y)
+ {
+ return true;
+ }
+
return Enumerable.SequenceEqual(
x.Where(c => !char.IsWhiteSpace(c)),
y.Where(c => !char.IsWhiteSpace(c)));

ADD
WalletWasabi.Tests/UnitTests/StringNoWhiteSpaceEqualityComparerTests.cs
+using System;
+using System.Collections.Generic;
+using System.Text;
+using WalletWasabi.Tests.Helpers;
+using Xunit;
+
+namespace WalletWasabi.Tests.UnitTests
+{
+ public class StringNoWhiteSpaceEqualityComparerTests
+ {
+ [Theory]
+ [InlineData(" a", "a ", true)]
+ [InlineData(" a", "b ", false)]
+ [InlineData(" a", "a\r\t\n ", true)]
+ [InlineData(" a", "b\r\t\n ", false)]
+ [InlineData("", "", true)]
+ [InlineData(null, null, true)]
+ [InlineData(null, "", false)]
+ public void StringNoWhiteSpaceEqualityComparerTest(string a, string b, bool equal)
+ {
+ if (equal)
+ {
+ Assert.Equal(a, b, new StringNoWhiteSpaceEqualityComparer());
+ Assert.Equal(b, a, new StringNoWhiteSpaceEqualityComparer());
+ }
+ else
+ {
+ Assert.NotEqual(a, b, new StringNoWhiteSpaceEqualityComparer());
+ Assert.NotEqual(b, a, new StringNoWhiteSpaceEqualityComparer());
+ }
+ }
+ }
+}

Add tests for StringNoWhiteSpaceEqualityComparerTests