public void SuppressChangeNotificationsShouldThrowObjectDisposedExceptionAfterDictionaryDisposal() { // given var observableDictionary = new ObservableDictionary<int, string>(); observableDictionary.Dispose(); // when Action action = () => { var suppression = observableDictionary.SuppressChangeNotifications(); }; action .ShouldThrow<ObjectDisposedException>() .WithMessage($"Cannot access a disposed object.\r\nObject name: '{observableDictionary.GetType().Name}'."); }
public void IsTrackingChangesReturnsCorrectValue() { // given using (var observableDictionary = new ObservableDictionary<int, string>()) { // when using (observableDictionary.SuppressChangeNotifications()) { observableDictionary.IsTrackingChanges.Should().BeFalse(); } observableDictionary.IsTrackingChanges.Should().BeTrue(); } }
public void SuppressChangeNotificationsPreventsMultipleSuppressions() { // given using (var observableDictionary = new ObservableDictionary<int, string>()) { // when using (observableDictionary.SuppressChangeNotifications()) { Action action = () => { var secondSuppression = observableDictionary.SuppressChangeNotifications(); }; action .ShouldThrow<InvalidOperationException>() .WithMessage("A Change Notification Suppression is currently already ongoing, multiple concurrent suppressions are not supported."); } } }