public void StructurallyEqualsWorks() { var n1 = null as object; var n2 = null as object; var o1 = new object(); var o2 = new object(); var t1 = new EqualityTester { Id = 1 }; var t2 = new EqualityTester { Id = 1 }; var t3 = new EqualityTester { Id = 3 }; var s = "foo"; Assert.True(n1.StructurallyEquals(null)); Assert.True(n1.StructurallyEquals(n1)); Assert.True(n1.StructurallyEquals(n2)); Assert.True(o1.StructurallyEquals(o1)); Assert.True(t1.StructurallyEquals(t1)); Assert.True(s.StructurallyEquals(s)); Assert.False(o1.StructurallyEquals(null)); Assert.False(o1.StructurallyEquals(n1)); Assert.False(n1.StructurallyEquals(o1)); Assert.False(s.StructurallyEquals(o1)); Assert.False(t1.StructurallyEquals(s)); Assert.False(o1.StructurallyEquals(o2)); Assert.False(o1.StructurallyEquals(s)); Assert.True(t1.StructurallyEquals(t2)); Assert.False(t1.StructurallyEquals(t3)); }
public void StructurallyEqualsWorks() { var n1 = null as object; var n2 = null as object; var o1 = new object(); var o2 = new object(); var t1 = new EqualityTester { Id = 1 }; var t2 = new EqualityTester { Id = 1 }; var t3 = new EqualityTester { Id = 3 }; var s = "foo"; Assert.True(n1.StructurallyEquals(null)); Assert.True(n1.StructurallyEquals(n1)); Assert.True(n1.StructurallyEquals(n2)); Assert.True(o1.StructurallyEquals(o1)); Assert.True(t1.StructurallyEquals(t1)); Assert.True(s.StructurallyEquals(s)); Assert.False(o1.StructurallyEquals(null)); Assert.False(o1.StructurallyEquals(n1)); Assert.False(n1.StructurallyEquals(o1)); Assert.False(s.StructurallyEquals(o1)); Assert.False(t1.StructurallyEquals(s)); Assert.False(o1.StructurallyEquals(o2)); Assert.False(o1.StructurallyEquals(s)); Assert.True(t1.StructurallyEquals(t2)); Assert.False(t1.StructurallyEquals(t3)); }