コード例 #1
0
        public void EventPattern_Equality()
        {
            var e1 = new EventPattern <string, EventArgs>("Bart", EventArgs.Empty);
            var e2 = new EventPattern <string, EventArgs>("Bart", EventArgs.Empty);

            Assert.True(e1.Equals(e1));
            Assert.True(e1.Equals(e2));
            Assert.True(e2.Equals(e1));
            Assert.True(e1 == e2);
            Assert.True(!(e1 != e2));
            Assert.True(e1.GetHashCode() == e2.GetHashCode());

            Assert.False(e1.Equals(null));
            Assert.False(e1.Equals("xy"));
            Assert.False(e1 == null);
        }
コード例 #2
0
        public void EventPattern_Inequality()
        {
            var a1 = new MyEventArgs();
            var a2 = new MyEventArgs();

            var e1 = new EventPattern <string, MyEventArgs>("Bart", a1);
            var e2 = new EventPattern <string, MyEventArgs>("John", a1);
            var e3 = new EventPattern <string, MyEventArgs>("Bart", a2);

            Assert.True(!e1.Equals(e2));
            Assert.True(!e2.Equals(e1));
            Assert.True(!(e1 == e2));
            Assert.True(e1 != e2);
            Assert.True(e1.GetHashCode() != e2.GetHashCode());

            Assert.True(!e1.Equals(e3));
            Assert.True(!e3.Equals(e1));
            Assert.True(!(e1 == e3));
            Assert.True(e1 != e3);
            Assert.True(e1.GetHashCode() != e3.GetHashCode());
        }