コード例 #1
0
        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}'.");
        }
コード例 #2
0
        public void IsTrackingChangesReturnsCorrectValue()
        {
            // given
            using (var observableDictionary = new ObservableDictionary<int, string>())
            {
                // when
                using (observableDictionary.SuppressChangeNotifications())
                {
                    observableDictionary.IsTrackingChanges.Should().BeFalse();
                }

                observableDictionary.IsTrackingChanges.Should().BeTrue();
            }
        }
コード例 #3
0
        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.");
                }
            }
        }