示例#1
0
        public new void ToString()
        {
            var name   = "MyEvent";
            var event_ = CustomEventInfoObjectMother.Create(name: name, addMethod: _publicAddMethod, removeMethod: _publicRemoveMethod);

            Assert.That(event_.ToString(), Is.EqualTo("MyEventDelegate MyEvent"));
        }
示例#2
0
        public void GetCustomAttributeData()
        {
            var customAttributes = new[] { CustomAttributeDeclarationObjectMother.Create() };
            var evt = CustomEventInfoObjectMother.Create(customAttributes: customAttributes);
            var evtInstantiation = new EventOnTypeInstantiation(_declaringType, evt, _addMethod, _removeMethod, _raiseMethod);

            Assert.That(evtInstantiation.GetCustomAttributeData(), Is.EqualTo(customAttributes));
        }
示例#3
0
        public void GetRemoveMethod()
        {
            var event1 = CustomEventInfoObjectMother.Create(removeMethod: _publicRemoveMethod, addMethod: _publicAddMethod);
            var event2 = CustomEventInfoObjectMother.Create(removeMethod: _nonPublicRemoveMethod, addMethod: _nonPublicAddMethod);

            Assert.That(event1.GetRemoveMethod(true), Is.SameAs(_publicRemoveMethod));
            Assert.That(event1.GetRemoveMethod(false), Is.SameAs(_publicRemoveMethod));
            Assert.That(event2.GetRemoveMethod(true), Is.SameAs(_nonPublicRemoveMethod));
            Assert.That(event2.GetRemoveMethod(false), Is.Null);
        }
示例#4
0
        public void ToDebugString()
        {
            var declaringType = CustomTypeObjectMother.Create(name: "MyType");
            var name          = "MyEvent";
            var event_        = CustomEventInfoObjectMother.Create(declaringType, name, addMethod: _publicAddMethod, removeMethod: _publicRemoveMethod);

            var expected = "TestableCustomEvent = \"MyEventDelegate MyEvent\", DeclaringType = \"MyType\"";

            Assert.That(event_.ToDebugString(), Is.EqualTo(expected));
        }
示例#5
0
        public void CustomAttributeMethods()
        {
            var event_ = CustomEventInfoObjectMother.Create(
                customAttributes: new[] { CustomAttributeDeclarationObjectMother.Create(typeof(ObsoleteAttribute)) });

            Assert.That(event_.GetCustomAttributes(false).Select(a => a.GetType()), Is.EqualTo(new[] { typeof(ObsoleteAttribute) }));
            Assert.That(event_.GetCustomAttributes(typeof(NonSerializedAttribute), false), Is.Empty);

            Assert.That(event_.IsDefined(typeof(ObsoleteAttribute), false), Is.True);
            Assert.That(event_.IsDefined(typeof(NonSerializedAttribute), false), Is.False);
        }
示例#6
0
        public void GetRaiseMethod()
        {
            var event1 = CustomEventInfoObjectMother.Create(raiseMethod: _publicRaiseMethod);
            var event2 = CustomEventInfoObjectMother.Create(raiseMethod: _nonPublicRaiseMethod);
            var event3 = CustomEventInfoObjectMother.Create(raiseMethod: null);

            Assert.That(event1.GetRaiseMethod(true), Is.SameAs(_publicRaiseMethod));
            Assert.That(event1.GetRaiseMethod(false), Is.SameAs(_publicRaiseMethod));
            Assert.That(event2.GetRaiseMethod(true), Is.SameAs(_nonPublicRaiseMethod));
            Assert.That(event2.GetRaiseMethod(false), Is.Null);
            Assert.That(event3.GetRaiseMethod(true), Is.Null);
            Assert.That(event3.GetRaiseMethod(false), Is.Null);
        }
示例#7
0
        public void UnsupportedMembers()
        {
            var event_ = CustomEventInfoObjectMother.Create();

            UnsupportedMemberTestHelper.CheckProperty(() => event_.ReflectedType, "ReflectedType");
        }