Beispiel #1
0
        public void ClearOne()
        {
            var before = new[] { 1 };
            var ints   = new ObservableCollection <int>(before);

            ints.Clear();
            var actual = Diff.CollectionChange(new[] { 1 }, ints);

            AssertEx.AreEqual(Diff.CreateRemoveEventArgs(1, 0), actual);
        }
Beispiel #2
0
        public void NoChangeNoEvent()
        {
            var change   = Diff.CollectionChange(new[] { 1, 2, 3 }, new[] { 1, 2, 3 });
            var notifier = new DummyNotifier();
            var actual   = notifier.SubscribeAll();

            Notifier.Notify(notifier, change, null, notifier.PropertyChangedEventHandler, notifier.NotifyCollectionChangedEventHandler);

            CollectionAssert.IsEmpty(actual);
        }
Beispiel #3
0
        public void RemoveLast()
        {
            var before   = new[] { 1 };
            var ints     = new ObservableCollection <int>(before);
            var expected = ints.CollectionChange();

            ints.Remove(1);
            var actual = Diff.CollectionChange(before, ints);

            AssertEx.AreEqual(expected.Value, actual);
        }
Beispiel #4
0
        public void Insert(int index)
        {
            var before   = new[] { 1, 2, 3 };
            var ints     = new ObservableCollection <int>(before);
            var expected = ints.CollectionChange();

            ints.Insert(index, 4);
            var actual = Diff.CollectionChange(before, ints);

            AssertEx.AreEqual(expected.Value, actual);
        }
Beispiel #5
0
        public void AddToEmpty()
        {
            var ints     = new ObservableCollection <int>();
            var expected = ints.CollectionChange();

            ints.Add(1);

            var actual = Diff.CollectionChange(new int[0], ints);

            AssertEx.AreEqual(expected.Value, actual);
        }
Beispiel #6
0
        public void Replace()
        {
            var before   = new[] { 1, 2, 3 };
            var ints     = new ObservableCollection <int>(before);
            var expected = ints.CollectionChange();

            ints[0] = 5;
            var actual = Diff.CollectionChange(before, ints);

            AssertEx.AreEqual(expected.Value, actual);
        }
Beispiel #7
0
        public void AddRefType()
        {
            var before   = new[] { new Fake(), new Fake(), new Fake() };
            var ints     = new ObservableCollection <Fake>(before);
            var expected = ints.CollectionChange();

            ints.Add(new Fake());

            var actual = Diff.CollectionChange(before, ints);

            AssertEx.AreEqual(expected.Value, actual);
        }
Beispiel #8
0
        public void Remove(int index)
        {
            var before   = new[] { 1, 2, 3 };
            var ints     = new ObservableCollection <int>(before);
            var expected = ints.SubscribeAll();
            var notifier = new DummyNotifier();
            var actual   = notifier.SubscribeAll();

            ints.RemoveAt(index);
            var change = Diff.CollectionChange(before, ints);

            Notifier.Notify(notifier, change, null, notifier.PropertyChangedEventHandler, notifier.NotifyCollectionChangedEventHandler);

            CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default);
        }
Beispiel #9
0
        public void AddToEmpty()
        {
            var ints     = new ObservableCollection <int>();
            var expected = ints.SubscribeAll();

            ints.Add(1);
            var notifier = new DummyNotifier();
            var actual   = notifier.SubscribeAll();

            var change = Diff.CollectionChange(new int[0], ints);

            Notifier.Notify(notifier, change, null, notifier.PropertyChangedEventHandler, notifier.NotifyCollectionChangedEventHandler);

            CollectionAssert.AreEqual(expected, actual, EventArgsComparer.Default);
        }
Beispiel #10
0
        public void NoChange()
        {
            var actual = Diff.CollectionChange(new[] { 1, 2, 3 }, new[] { 1, 2, 3 });

            Assert.IsNull(actual);
        }