Example #1
0
        public void WeakEventManager_UnassignedEventManager()
        {
            // Arrange
            var unassignedEventManager = new DelegateWeakEventManager();
            var didEventFire           = false;

            TestEvent += HandleTestEvent;
            void HandleTestEvent(object?sender, EventArgs e) => didEventFire = true;

            // Act
            unassignedEventManager.RaiseEvent(null, null, nameof(TestEvent));

            // Assert
            Assert.False(didEventFire);
            TestEvent -= HandleTestEvent;
        }
        public void WeakEventManager_UnassignedEventManager()
        {
            // Arrange
            var unassignedEventManager = new DelegateWeakEventManager();
            var didEventFire           = false;

            TestEvent += HandleTestEvent;
            void HandleTestEvent(object?sender, EventArgs e) => didEventFire = true;

            // Act
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
            unassignedEventManager.RaiseEvent(null, null, nameof(TestEvent));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.

            // Assert
            Assert.False(didEventFire);
            TestEvent -= HandleTestEvent;
        }