예제 #1
0
        public void StaticMapEqualsWorks()
        {
            {
                MyComposite sm1 = new MyComposite {
                    si = 42, ss1 = "foo", ss2 = null, nested = new MyComposite.MyNested {
                        x = 10, y = 20, s = "bar"
                    }, ci = null
                };
                MyComposite sm2 = new MyComposite {
                    si = 42, ss1 = "foo", ss2 = null, nested = new MyComposite.MyNested {
                        x = 10, y = 20, s = "bar"
                    }, ci = null
                };
                Assert.True(sm1.Equals(sm2));
                Assert.False(sm1.Equals(null));
            }

            {
                MyComposite sm1 = new MyComposite {
                    ss1 = null, ss2 = "foo"
                };
                MyComposite sm2 = new MyComposite {
                    ss1 = "foo", ss2 = null
                };
                Assert.False(sm1.Equals(sm2));
                Assert.False(sm2.Equals(sm1));
            }
        }
예제 #2
0
        public void StaticMapEqualsCallsItemEquals()
        {
            {
                MyFalseEquatableItem e = new MyFalseEquatableItem();

                MyComposite sm1 = new MyComposite {
                    ci = e
                };
                MyComposite sm2 = new MyComposite {
                    ci = e
                };
                Assert.False(sm1.Equals(sm2));
            }

            {
                MyComposite sm1 = new MyComposite {
                    ci = new MyTrueEquatableItem()
                };
                MyComposite sm2 = new MyComposite {
                    ci = new MyTrueEquatableItem()
                };
                Assert.True(sm1.Equals(sm2));
            }
        }