public void TestListsEqualSimple() { Assert.IsTrue(DiffUtil.ListsEqual( (List <int>)null, null ), "equal (both null)"); Assert.IsTrue(DiffUtil.ListsEqual( new List <int> { 1, 2, 3 }, new List <int> { 1, 2, 3 } ), "equal (values)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <int> { 1, 2, 3 }, null ), "not equal (second null)"); Assert.IsFalse(DiffUtil.ListsEqual( null, new List <int> { 1, 2, 3 } ), "not equal (first null)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <int> { 1, 2, 3 }, new List <int> { 1, 2, 4 } ), "not equal (values)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <int> { 1, 2, 3 }, new List <int> { 1, 3, 2 } ), "not equal (order)"); }
public void TestListsEqualObj() { var x = new MockType { Some = 108, Thing = "Hello_X" }; var y = new MockType { Some = 108, Thing = "Hello_Y" }; var z = new MockType { Some = 108, Thing = "Hello_Z" }; var z2 = new MockType { Some = 108, Thing = "Hello_Z" }; var a = new MockType { Some = 108, Thing = "Hello_A" }; Assert.IsTrue(DiffUtil.ListsEqual( (List <object>)null, null ), "equal (null)"); Assert.IsTrue(DiffUtil.ListsEqual( new List <object> { x, y, z }, new List <object> { x, y, z } ), "equal (values)"); Assert.IsFalse(DiffUtil.ListsEqual( null, new List <object> { x, y, z } ), "not equal (first null)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <object> { x, y, z }, null ), "not equal (second null)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <object> { x, y, z }, new List <object> { x, y, a } ), "not equal (values)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <object> { x, y, z }, new List <object> { x, z, y } ), "not equal (order)"); Assert.IsFalse(DiffUtil.ListsEqual( new List <object> { x, y, z }, new List <object> { x, y, z2 } ), "not equal (same value, but not same reference)"); }