mirror of
https://onedev.fprog.nl/AioNet
synced 2025-12-21 06:48:38 +01:00
134 lines
3.3 KiB
C#
134 lines
3.3 KiB
C#
using System.Drawing;
|
|
using AioNet.Reflection;
|
|
|
|
namespace AioNet.ReflectionTest;
|
|
|
|
public class DeepComparisonTest
|
|
{
|
|
[Fact]
|
|
public void IntComparison()
|
|
{
|
|
Assert.True(1.RecursiveFieldsEqual(1));
|
|
}
|
|
|
|
[Fact]
|
|
public void IntFalseComparison()
|
|
{
|
|
Assert.False(1.RecursiveFieldsEqual(2));
|
|
}
|
|
|
|
[Fact]
|
|
public void StringComparison()
|
|
{
|
|
Assert.True("some string".RecursiveFieldsEqual("some string"));
|
|
}
|
|
|
|
[Fact]
|
|
public void StringFalseComparison()
|
|
{
|
|
Assert.False("some string".RecursiveFieldsEqual("some-string"));
|
|
}
|
|
|
|
[Fact]
|
|
public void NullComparison()
|
|
{
|
|
Assert.True(DeepComparison.RecursiveFieldsEqual<string>(null, null));
|
|
}
|
|
|
|
[Fact]
|
|
public void NullFirstFalseComparison()
|
|
{
|
|
Assert.False(DeepComparison.RecursiveFieldsEqual(null, "some-string"));
|
|
}
|
|
|
|
[Fact]
|
|
public void NullSecondFalseComparison()
|
|
{
|
|
Assert.False("some string".RecursiveFieldsEqual(null));
|
|
}
|
|
|
|
[Fact]
|
|
public void TupleComparison()
|
|
{
|
|
Assert.True((1, "true").RecursiveFieldsEqual((1, "true")));
|
|
}
|
|
|
|
[Fact]
|
|
public void TupleFalseComparison()
|
|
{
|
|
Assert.False((1, "true").RecursiveFieldsEqual((1, "truo")));
|
|
}
|
|
|
|
[Fact]
|
|
public void PointComparison()
|
|
{
|
|
Point point1 = new Point { X = 55, Y = 99 };
|
|
|
|
Point point2 = new Point { X = 55, Y = 99 };
|
|
|
|
Assert.True(point1.RecursiveFieldsEqual(point2));
|
|
}
|
|
|
|
[Fact]
|
|
public void PointFalseComparison()
|
|
{
|
|
Point point1 = new Point { X = 55, Y = 99 };
|
|
|
|
Point point2 = new Point { X = 55, Y = 91 };
|
|
|
|
Assert.False(point1.RecursiveFieldsEqual(point2));
|
|
}
|
|
|
|
[Fact]
|
|
public void ArrayComparison()
|
|
{
|
|
int[] x = new[] { 1, 2, 3 };
|
|
int[] y = new[] { 1, 2, 3 };
|
|
Assert.True(x.RecursiveFieldsEqual(y));
|
|
}
|
|
|
|
[Fact]
|
|
public void ArrayFalseComparison()
|
|
{
|
|
int[] x = new[] { 1, 2, 3 };
|
|
int[] y = new[] { 1, 1, 3 };
|
|
Assert.False(x.RecursiveFieldsEqual(y));
|
|
}
|
|
|
|
[Fact]
|
|
public void DictionaryComparison()
|
|
{
|
|
Dictionary<string, string> first = new Dictionary<string, string> { { "one", "two" } };
|
|
Dictionary<string, string> second = new Dictionary<string, string> { { "one", "two" } };
|
|
|
|
Assert.True(first.RecursiveFieldsEqual(second));
|
|
}
|
|
|
|
[Fact]
|
|
public void DictionaryKeyFalseComparison()
|
|
{
|
|
Dictionary<string, string> first = new Dictionary<string, string> { { "one", "two" } };
|
|
Dictionary<string, string> second = new Dictionary<string, string> { { "six", "two" } };
|
|
|
|
Assert.False(first.RecursiveFieldsEqual(second));
|
|
}
|
|
|
|
[Fact]
|
|
public void DictionaryValueFalseComparison()
|
|
{
|
|
Dictionary<string, string> first = new Dictionary<string, string> { { "one", "two" } };
|
|
Dictionary<string, string> second = new Dictionary<string, string> { { "one", "six" } };
|
|
|
|
Assert.False(first.RecursiveFieldsEqual(second));
|
|
}
|
|
|
|
[Fact]
|
|
public void HashSetComparison()
|
|
{
|
|
HashSet<string> first = new HashSet<string> { "banana", "apple", "orange" };
|
|
HashSet<string> second = new HashSet<string> { "banana", "apple", "orange" };
|
|
|
|
Assert.True(first.RecursiveFieldsEqual(second));
|
|
}
|
|
}
|