Пример #1
0
        private static ReadOnlyObservableCollection <ValidationError> Create(int n)
        {
            var errors = new ObservableCollection <ValidationError>();

            for (int i = 0; i < n; i++)
            {
                errors.Add(TestValidationError.Create());
            }

            return(new ReadOnlyObservableCollection <ValidationError>(errors));
        }
Пример #2
0
        public void RefreshRemoveSingleNull()
        {
            var error     = TestValidationError.Create();
            var reference = new ObservableCollection <ValidationError> {
                error
            };
            var expectedEvents = reference.SubscribeAllEvents();
            var errors         = new ErrorCollection {
                error
            };
            var allEvents = errors.SubscribeAllEvents();

            errors.Refresh(null);
            reference.Remove(error);

            CollectionAssert.AreEqual(expectedEvents, allEvents, ObservableCollectionArgsComparer.Default);
            CollectionAssert.AreEqual(reference, errors);
        }
Пример #3
0
        public void RefreshAddMany()
        {
            var error  = TestValidationError.Create();
            var errors = new ErrorCollection {
                error
            };
            var allEvents = errors.SubscribeAllEvents();
            var newErrors = Create(3);

            errors.Refresh(newErrors);

            var expectedEvents = new List <EventArgs>
            {
                new PropertyChangedEventArgs("Count"),
                new PropertyChangedEventArgs("Item[]"),
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)
            };

            CollectionAssert.AreEqual(expectedEvents, allEvents, ObservableCollectionArgsComparer.Default);
            CollectionAssert.AreEqual(newErrors, errors);
        }