public void AddTest()
        {
            var item1 = new TestBase(1);
            var item2 = new TestBase(2);

            mBackingCollection.Add(item1);
            mBackingCollection.Add(item2);

            _AssertBackingAndWrappedAreSynced();

            Assert.That(mCollectionChangedEvents.Count, Is.EqualTo(2));
            Assert.AreEqual(NotifyCollectionChangedAction.Add, mCollectionChangedEvents[0].Action);
            Assert.That(mCollectionChangedEvents[0].NewItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item1), mCollectionChangedEvents[0].NewItems[0]);
            Assert.IsNull(mCollectionChangedEvents[0].OldItems);

            Assert.AreEqual(NotifyCollectionChangedAction.Add, mCollectionChangedEvents[1].Action);
            Assert.That(mCollectionChangedEvents[1].NewItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item2), mCollectionChangedEvents[1].NewItems[0]);
            Assert.IsNull(mCollectionChangedEvents[1].OldItems);
        }
        public void MoveTest()
        {
            var item1 = new TestBase(1);
            var item2 = new TestBase(2);
            var item3 = new TestBase(3);

            _Setup(item1, item2, item3);

            mBackingCollection.Move(1, 2);

            Assert.That(mBackingCollection, Is.EqualTo(new[] {item1, item3, item2}));

            _AssertBackingAndWrappedAreSynced();

            Assert.That(mCollectionChangedEvents.Count, Is.EqualTo(1));
            Assert.AreEqual(NotifyCollectionChangedAction.Move, mCollectionChangedEvents[0].Action);
            Assert.That(mCollectionChangedEvents[0].OldItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item2), mCollectionChangedEvents[0].OldItems[0]);
            Assert.That(mCollectionChangedEvents[0].NewItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item2), mCollectionChangedEvents[0].NewItems[0]);
            Assert.AreEqual(1, mCollectionChangedEvents[0].OldStartingIndex);
            Assert.AreEqual(2, mCollectionChangedEvents[0].NewStartingIndex);
        }
        public void RemoveTest()
        {
            var item1 = new TestBase(1);
            var item2 = new TestBase(2);
            var item3 = new TestBase(3);

            _Setup(item1, item2, item3);

            mBackingCollection.Remove(item2);

            Assert.That(mBackingCollection.Count, Is.EqualTo(2));
            Assert.AreSame(item1, mBackingCollection[0]);
            Assert.AreSame(item3, mBackingCollection[1]);

            _AssertBackingAndWrappedAreSynced();

            Assert.That(mCollectionChangedEvents.Count, Is.EqualTo(1));
            Assert.AreEqual(NotifyCollectionChangedAction.Remove, mCollectionChangedEvents[0].Action);
            Assert.That(mCollectionChangedEvents[0].OldItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item2), mCollectionChangedEvents[0].OldItems[0]);
            Assert.IsNull(mCollectionChangedEvents[0].NewItems);
        }
 /// <summary>
 ///   Initializes a new instance of the <see cref = "TestWrapper" /> class.
 /// </summary>
 /// <param name = "base">The @base.</param>
 public TestWrapper(TestBase @base)
 {
     mBase = @base;
 }
 public bool Equals(TestBase other)
 {
     if (ReferenceEquals(null, other))
     {
         return false;
     }
     if (ReferenceEquals(this, other))
     {
         return true;
     }
     return other.Number == Number;
 }
 /// <summary>
 ///   Wraps a <see cref = "TestBase" /> into a <see cref = "TestWrapper" />.
 /// </summary>
 private static TestWrapper _Wrap(TestBase arg)
 {
     return new TestWrapper(arg);
 }
        public void ResetTest()
        {
            var item1 = new TestBase(1);
            var item2 = new TestBase(2);
            var item3 = new TestBase(3);

            _Setup(item1, item2, item3);

            mBackingCollection.Clear();

            Assert.That(mBackingCollection, Is.Empty);

            _AssertBackingAndWrappedAreSynced();

            Assert.That(mCollectionChangedEvents.Count, Is.EqualTo(1));
            Assert.AreEqual(NotifyCollectionChangedAction.Reset, mCollectionChangedEvents[0].Action);
            Assert.IsNull(mCollectionChangedEvents[0].OldItems);
            Assert.IsNull(mCollectionChangedEvents[0].NewItems);
        }
        public void ReplaceTest()
        {
            var item1 = new TestBase(1);
            var item2 = new TestBase(2);
            var item3 = new TestBase(3);

            _Setup(item1, item2, item3);

            mBackingCollection[0] = item2;

            Assert.That(mBackingCollection, Is.EqualTo(new[] {item2, item2, item3}));

            _AssertBackingAndWrappedAreSynced();

            Assert.That(mCollectionChangedEvents.Count, Is.EqualTo(1));
            Assert.AreEqual(NotifyCollectionChangedAction.Replace, mCollectionChangedEvents[0].Action);
            Assert.That(mCollectionChangedEvents[0].OldItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item1), mCollectionChangedEvents[0].OldItems[0]);
            Assert.That(mCollectionChangedEvents[0].NewItems.Count, Is.EqualTo(1));
            Assert.AreEqual(_Wrap(item2), mCollectionChangedEvents[0].NewItems[0]);
        }