Example #1
0
        public void given_blist_when_item_removed_then_collectionchanged_raised()
        {
            var blist = new BList<int>();

            var initial = new int[32].Select(_ => _random.Next()).ToArray();
            var expected = initial[16];

            blist.AddRange(initial);

            NotifyCollectionChangedEventArgs args = null;
            blist.CollectionChanged += (_, a) => args = a;

            blist.RemoveAt(16);

            Assert.That(args, Is.Not.Null);
            Assert.That(args.Action, Is.EqualTo(NotifyCollectionChangedAction.Remove));
            Assert.That(args.OldStartingIndex, Is.EqualTo(16));
            Assert.That(args.OldItems[0], Is.EqualTo(expected));
        }
Example #2
0
            given_existing_blist_when_elements_are_removed_by_index_with_zero_index_then_blist_iterator_should_return_correct_elements
            ()
        {
            var initial = new int[512].Select(_ => _random.Next()).ToArray();
            var expected = initial.Skip(32).ToArray();

            var blist = new BList<int>();

            foreach (var item in initial)
                blist.Add(item);

            for (int i = 0; i < 32; i++)
            {
                blist.RemoveAt(0);
            }

            Assert.That(blist.Count, Is.EqualTo(480));

            CollectionAssert.AreEqual(expected, blist);
        }