public void ResetTest()
        {
            const int index = 0;
            var       item  = new CollectionModel();

            _changeSetProvider.Publish(new ChangeSet <CollectionModel>(new[] { new Change <CollectionModel>(ListChangeReason.Add, item, index), }));

            _changeSetProvider.Publish(new ChangeSet <CollectionModel>(new[] { new Change <CollectionModel>(ListChangeReason.Clear, new CollectionModel[] { item }, 0), }));
            Assert.Equal(0, _store.Count);
        }
        public void AddTest()
        {
            const int index = 0;
            var       item  = new CollectionModel();

            _changeSetProvider.Publish(new ChangeSet <CollectionModel>(new[] { new Change <CollectionModel>(ListChangeReason.Add, item, index), }));

            Assert.Equal(1, _store.Count);
            Assert.Same(item, _store.Items[0]);
            Assert.Same(item, _store.Get(0));
        }
        public void ContainsTest()
        {
            var contains = _store.Contains(0);

            Assert.False(contains);

            const int index = 0;
            var       item  = new CollectionModel();

            _changeSetProvider.Publish(new ChangeSet <CollectionModel>(new[] { new Change <CollectionModel>(ListChangeReason.Add, item, index), }));

            contains = _store.Contains(0);
            Assert.True(contains);
        }
Пример #4
0
        public void AddedItemInBackingRaisesEventTest()
        {
            NotifyCollectionChangedEventArgs receivedEventArgs = null;

            _collection.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs args)
            {
                receivedEventArgs = args;
            };

            var index = 23;
            var item  = new CollectionModel();

            _changeSetProvider.Publish(new ChangeSet <CollectionModel>(new [] { new Change <CollectionModel>(ListChangeReason.Add, item, index), }));

            Assert.NotNull(receivedEventArgs);
            Assert.Equal(NotifyCollectionChangedAction.Add, receivedEventArgs.Action);
            Assert.Equal(index, receivedEventArgs.NewStartingIndex);
            Assert.Equal(1, receivedEventArgs.NewItems.Count);
            Assert.Same(item, receivedEventArgs.NewItems[0]);
        }