Ejemplo n.º 1
0
    public void ReplaceRangeTest()
    {
        var c        = new RangedObservableCollection <Person>();
        var filtered = c.ToFilteredReadOnlyObservableCollection(x => x.IsRemoved);
        var people   = Enumerable.Range(1, 1000000).Select(x => new Person
        {
            Name      = $"tanaka {x}",
            IsRemoved = x % 2 == 0,
        });

        c.ReplaceRange(people);
        filtered.Count.Is(500000);
    }
Ejemplo n.º 2
0
        public void ReplaceRangeRaisesCorrectCollectionChangedEvent()
        {
            var collection = new RangedObservableCollection <int>();

            collection.AddRange(ItemsToAdd);

            collection.CollectionChanged += (s, e) =>
            {
                Assert.Equal(NotifyCollectionChangedAction.Reset, e.Action);
                Assert.Null(e.OldItems);
                Assert.Null(e.NewItems);
            };

            collection.ReplaceRange(AlternateItemsToAdd);

            Assert.Equal(AlternateItemsToAdd, collection.ToArray());
        }
Ejemplo n.º 3
0
        public void ReplaceRangeRaisesCollectionChangedOnce()
        {
            var collection = new RangedObservableCollection <int>();

            collection.AddRange(ItemsToAdd);

            var didTrigger = false;

            collection.CollectionChanged += (s, e) =>
            {
                Assert.False(didTrigger);
                didTrigger = true;
            };

            collection.ReplaceRange(AlternateItemsToAdd);

            Assert.True(didTrigger);
        }