Browse Source

Fix equality test.

pull/544/head 4.5.1
Sebastian 6 years ago
parent
commit
ff8dc10a22
  1. 9
      backend/src/Squidex.Infrastructure/Reflection/SimpleEquals.cs
  2. 6
      backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleEqualsTests.cs

9
backend/src/Squidex.Infrastructure/Reflection/SimpleEquals.cs

@ -18,9 +18,16 @@ namespace Squidex.Infrastructure.Reflection
public static class SimpleEquals
{
private static readonly ConcurrentDictionary<Type, IDeepComparer> Comparers = new ConcurrentDictionary<Type, IDeepComparer>();
private static readonly HashSet<Type> SimpleTypes = new HashSet<Type>();
private static readonly DefaultComparer DefaultComparer = new DefaultComparer();
private static readonly NoopComparer NoopComparer = new NoopComparer();
static SimpleEquals()
{
SimpleTypes.Add(typeof(string));
SimpleTypes.Add(typeof(Uri));
}
internal static IDeepComparer Build(Type type)
{
return BuildCore(type) ?? DefaultComparer;
@ -91,7 +98,7 @@ namespace Squidex.Infrastructure.Reflection
private static bool IsSimpleType(Type type)
{
return type.IsValueType || type == typeof(string);
return type.IsValueType || SimpleTypes.Contains(type);
}
private static bool IsEquatable(Type type)

6
backend/tests/Squidex.Infrastructure.Tests/Reflection/SimpleEqualsTests.cs

@ -84,6 +84,12 @@ namespace Squidex.Infrastructure.Reflection
TimeSpan.FromMilliseconds(123),
TimeSpan.FromMilliseconds(55)
};
yield return new object[]
{
new Uri("/url1", UriKind.Relative),
new Uri("/url2", UriKind.Relative),
};
}
[Theory]

Loading…
Cancel
Save