Ejemplo n.º 1
0
        public void WithoutSuppress_NotificationsHappen()
        {
            var testLocator     = new InternalLocator();
            var originalLocator = testLocator.Internal;

            int    numberNotifications = 0;
            Action notificationAction  = () => numberNotifications++;

            testLocator.RegisterResolverCallbackChanged(notificationAction);

            testLocator.SetLocator(new ModernDependencyResolver());
            testLocator.SetLocator(new ModernDependencyResolver());

            // 2 for the changes, 1 for the callback being immediately called.
            Assert.Equal(3, numberNotifications);

            testLocator.SetLocator(originalLocator);
        }
Ejemplo n.º 2
0
        public void WithSuppression_NotificationsDontHappen()
        {
            var testLocator     = new InternalLocator();
            var originalLocator = testLocator.Internal;

            using (testLocator.SuppressResolverCallbackChangedNotifications())
            {
                int    numberNotifications = 0;
                Action notificationAction  = () => numberNotifications++;

                testLocator.RegisterResolverCallbackChanged(notificationAction);

                testLocator.SetLocator(new ModernDependencyResolver());
                testLocator.SetLocator(new ModernDependencyResolver());

                Assert.Equal(0, numberNotifications);

                testLocator.SetLocator(originalLocator);
            }
        }