Example #1
0
        public virtual void CollectionShouldTrackChangesCorrectBatchSize()
        {
            const int count = 10;
            SynchronizedNotifiableCollection <Item> collection = CreateNotifiableCollection <Item>(ExecutionMode.None, ThreadManagerMock);

            collection.BatchSize = 10;
            var collectionTracker = new NotifiableCollectionTracker <Item>(collection);

            using (collection.SuspendNotifications())
            {
                var item   = new Item();
                var items  = new[] { new Item(), new Item(), new Item() };
                var items2 = new[] { new Item(), new Item(), new Item() };
                for (int i = 0; i < count; i++)
                {
                    collection.AddRange(items);
                    collection.AddRange(items2);
                    collection.RemoveRange(items);
                }
                for (int i = 0; i < collection.Count; i++)
                {
                    collection[i] = item;
                }
            }
            ThreadManagerMock.InvokeOnUiThreadAsync();
            collectionTracker.AssertEquals();
            collection.Count.ShouldEqual(count * 3);
        }
        public override void CollectionShouldTrackChangesCorrect()
        {
            const int count = 10;
            SynchronizedNotifiableCollection <Item> collection = CreateNotifiableCollection <Item>(ExecutionMode.None,
                                                                                                   ThreadManagerMock);
            var collectionTracker = new NotifiableCollectionTracker <Item>(collection);

            collection.BatchSize = int.MaxValue;
            var items  = new[] { new Item(), new Item(), new Item() };
            var items2 = new[] { new Item(), new Item(), new Item() };

            using (collection.SuspendNotifications())
            {
                for (int i = 0; i < count; i++)
                {
                    collection.AddRange(items);
                    collection.AddRange(items2);
                    collection.RemoveRange(items);
                }
            }
            collectionTracker.AssertEquals();
            collection.Count.ShouldEqual(count * 3);
        }