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); }
public void WithResolver_NotificationsDontHappen() { int numberNotifications = 0; Action notificationAction = () => numberNotifications++; var testLocator = new InternalLocator(); testLocator.RegisterResolverCallbackChanged(notificationAction); using (testLocator.Internal.WithResolver()) { using (testLocator.Internal.WithResolver()) { } } // 1 due to the fact the callback is called when we register. Assert.Equal(1, numberNotifications); }
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); } }