More unit tests for RecursiveFieldsEqual.

This commit is contained in:
Filip Strajnar 2024-05-11 18:49:48 +02:00
parent 953b090024
commit f04f6c7a71

View file

@ -86,4 +86,48 @@ public class DeepComparisonTest
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));
}
}