Exemple #1
0
        public void HasEventRecipients_NameofEventNameParam_NoSubscriber_ReturnsFalse()
        {
            // Arrange
            var stub = new EventClassStub();

            // Act
            var actualValue = CoClassEventReflector.HasEventRecipients(stub, typeof(EventClassStub), nameof(EventClassStub.Custom1Event));

            // Assert
            Assert.IsFalse(actualValue);
        }
Exemple #2
0
        public void HasEventRecipients_NameofEventNameParam_EventWithSubscriber_ReturnsTrue()
        {
            // Arrange
            var stub = new EventClassStub();

            stub.Custom1Event += (sender, args) => { };

            // Act
            var actualValue = CoClassEventReflector.HasEventRecipients(stub, typeof(EventClassStub), nameof(EventClassStub.Custom1Event));

            // Assert
            Assert.IsTrue(actualValue);
        }
Exemple #3
0
        public void HasEventRecipients_EventNameParam_NoSubscriberForNamedEvent_ReturnsFalse()
        {
            // Arrange
            var stub = new EventClassStub();

            stub.Custom1Event += (obj, arg) => { };

            // Act
            var actualValue = CoClassEventReflector.HasEventRecipients(stub, typeof(EventClassStub), "Custom2");

            // Assert
            Assert.IsFalse(actualValue);
        }
Exemple #4
0
        public void HasEventRecipients_EventNameParam_NonExistingEventName_ThrowsArgumentException()
        {
            // Arrange
            var stub = new EventClassStub();

            // Act & Assert
            var actualException = Assert.Throws <ArgumentOutOfRangeException>(
                () => CoClassEventReflector.HasEventRecipients(stub, typeof(EventClassStub), "NonExistingEventName")
                );

            Assert.AreEqual("eventName", actualException.ParamName);
            Assert.AreEqual("NonExistingEventName", actualException.ActualValue);
        }