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 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); } }