public void NotifyCollectionChangedEventArgsConstructor6Test()
        {
            var       changedItem   = new object();
            const int startingIndex = 5; // Doesn't matter what the value of this is.

            // Trying with Add
            var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItem, startingIndex);

            CollectionChangedEventValidators.ValidateAddOperation(args, new[] { changedItem }, startingIndex, "#F01");

            // Trying with Remove
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItem, startingIndex);

            CollectionChangedEventValidators.ValidateRemoveOperation(args, new[] { changedItem }, startingIndex, "#F02");

            // Trying with Reset
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, (object)null, -1);

            CollectionChangedEventValidators.ValidateResetOperation(args, "#F03");

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, changedItem, -1));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset unless changeItems is null");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, (object)null, 1));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset unless startingIndex is -1");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, changedItem, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Move
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, changedItem, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Move.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Replace
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, changedItem, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Replace.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }
        }
        public void NotifyCollectionChangedEventArgsConstructor3Test()
        {
            /* Expected Behavior:
             *
             * If action is Add, success.
             * If action is Remove, success.
             * If action is Reset:
             *    If changedItem is null, success.
             *    If changedItem is non-null, throw an Argument Exception
             * If action is Move or Replace, throw an Argument Exception
             */

            var changedItem = new object();

            // Trying with Add
            var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItem);

            CollectionChangedEventValidators.ValidateAddOperation(args, new[] { changedItem }, "#C01");

            // Trying with Remove
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItem);

            CollectionChangedEventValidators.ValidateRemoveOperation(args, new[] { changedItem }, "#C02");

            // Trying with Reset

            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, (object)null);

            CollectionChangedEventValidators.ValidateResetOperation(args, "#C03");

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, changedItem));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Move
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, changedItem));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Move.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Replace
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, changedItem));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Replace.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }
        }
        public void NotifyCollectionChangedEventArgsConstructor5Test()
        {
            /* Expected Behavior:
             *
             * If action is Add or Remove:
             *    If changedItems is null, throw an ArgumentNullException.
             *    If startingIndex < -1, throw an ArgumentException
             *    Otherwise, success.
             * If action is Reset:
             *    If changedItems is non-null, throw an ArgumentException
             *    If startingIndex != 0, throw an ArgumentException
             *    Otherwise, success.
             * If action is Move or Replace, throw an ArgumentException
             */

            IList     changedItems  = new List <object>();
            const int startingIndex = 5; // Doesn't matter what the value of this is.

            // Trying with Add
            var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems, startingIndex);

            CollectionChangedEventValidators.ValidateAddOperation(args, changedItems, startingIndex, "#E01");

            // Trying with Remove
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItems, startingIndex);

            CollectionChangedEventValidators.ValidateRemoveOperation(args, changedItems, startingIndex, "#E02");

            // Add some items to test this one.
            changedItems.Add(new object());
            changedItems.Add(new object());
            changedItems.Add(new object());

            // Trying with Add
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems, startingIndex);

            CollectionChangedEventValidators.ValidateAddOperation(args, changedItems, startingIndex, "#E03");

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems, -5));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Add if startingIndex < -1.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, null, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Add if changedItems is null.");
            }
            catch (ArgumentNullException ex)
            {
                No.Op(ex);
            }

            // Trying with Remove
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItems, startingIndex);

            CollectionChangedEventValidators.ValidateRemoveOperation(args, changedItems, startingIndex, "#E04");

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItems, -5));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Remove if startingIndex < -1.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, null, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Remove if changedItems is null.");
            }
            catch (ArgumentNullException ex)
            {
                No.Op(ex);
            }

            // Trying with Reset
            GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null, -1));

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, changedItems, -1));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset unless changeItems is null");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null, 1));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset unless startingIndex is -1");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, changedItems, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Move
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, changedItems, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Move.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Replace
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, changedItems, startingIndex));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Replace.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }
        }
        public void NotifyCollectionChangedEventArgsConstructor2Test()
        {
            /* Expected Behavior:
             *
             * If action is Add, success.
             * If action is Remove, success.
             * If action is Reset:
             *    If changedItems is null, success.
             *    If changedItems is non-null, throw an Argument Exception
             * If action is Move or Replace, throw an Argument Exception
             */

            IList changedItems = new List <object>();

            // Trying with Add
            var args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems);

            CollectionChangedEventValidators.ValidateAddOperation(args, changedItems, "#B01");

            // Trying to add a null array
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, null));
                Assert.Fail("Cannot call .ctor if changedItems is null.");
            }
            catch (ArgumentNullException ex)
            {
                No.Op(ex);
            }

            // Trying with Remove
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItems);

            CollectionChangedEventValidators.ValidateRemoveOperation(args, changedItems, "#B02");

            // Trying with Reset (works if changedItems is null)
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, null);

            CollectionChangedEventValidators.ValidateResetOperation(args, "#B03");

            try
            {
                args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset, changedItems);
                GC.KeepAlive(args);
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Reset.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Move
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, changedItems));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Move.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Trying with Replace
            try
            {
                GC.KeepAlive(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Replace, changedItems));
                Assert.Fail("Should not be able to call .ctor with NotifyCollectionChangedAction.Replace.");
            }
            catch (ArgumentException ex)
            {
                No.Op(ex);
            }

            // Add some items, and repeat
            changedItems.Add(new object());
            changedItems.Add(new object());
            changedItems.Add(new object());

            // Trying with Add
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, changedItems);

            CollectionChangedEventValidators.ValidateAddOperation(args, changedItems, "#B04");

            // Trying with Remove
            args = new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, changedItems);

            CollectionChangedEventValidators.ValidateRemoveOperation(args, changedItems, "#B05");
        }