示例#1
0
        public void GetCountOfEventRecipients_NameofEventName_WithNoSubscribers_ReturnsZero()
        {
            // Arrange
            var stub = new EventClassStub();

            // Act
            var actualCount = CoClassEventReflector.GetCountOfEventRecipients(stub, typeof(EventClassStub), nameof(EventClassStub.Custom1Event));

            // Assert
            Assert.AreEqual(0, actualCount);
        }
示例#2
0
        public void GetCountOfEventRecipients_NonExistingEventName_ThrowsArgumentException()
        {
            // Arrange
            var stub = new EventClassStub();

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

            Assert.AreEqual("eventName", actualException.ParamName);
            Assert.AreEqual("IncorrectEventName", actualException.ActualValue);
        }
示例#3
0
        public void GetCountOfEventRecipients_NameofEventName_WithMultipleSubscribers_ReturnsCorrectCount()
        {
            // Arrange
            var stub = new EventClassStub();

            stub.Custom1Event += OnCustom1EventHandler;

            stub.Custom2Event += OnCustom1EventHandler;
            stub.Custom2Event += OnCustom1EventHandler;

            stub.Custom3Event += OnCustom1EventHandler;
            stub.Custom3Event += OnCustom1EventHandler;
            stub.Custom3Event += OnCustom1EventHandler;

            // Act
            var actualCount = CoClassEventReflector.GetCountOfEventRecipients(stub, typeof(EventClassStub), nameof(EventClassStub.Custom3Event));

            // Assert
            Assert.AreEqual(3, actualCount);
        }