/// <summary>
        /// Verifies that the expected collection events are raised from the <see cref="ValidationResultCollection"/>
        /// for validation results with the specified member names.
        /// </summary>
        /// <param name="validationResultMemberNames">
        /// The array of member names to create validation results for that will be
        /// added and removed from the collection.
        /// </param>
        /// <param name="errorsChangedMemberNames">The array of member names to expect errors changed events for.</param>
        private static void VerifyAddRemoveCollectionEvents(string[] validationResultMemberNames, string[] errorsChangedMemberNames)
        {
            int           collectionChangedCount    = 0;
            int           hasErrorsChangedCount     = 0;
            List <string> propertyErrorsChangedList = new List <string>();

            Action          collectionChanged     = () => ++ collectionChangedCount;
            Action          hasErrorsChanged      = () => ++ hasErrorsChangedCount;
            Action <string> propertyErrorsChanged = propertyName => propertyErrorsChangedList.Add(propertyName);

            ValidationResultCollection collection = new TestValidationResultCollection(collectionChanged, hasErrorsChanged, propertyErrorsChanged);
            ValidationResult           vr1        = new ValidationResult("Error 1", validationResultMemberNames);

            collection.Add(vr1);

            Assert.AreEqual <int>(1, collectionChangedCount, "CollectionChanged count for first add");
            Assert.AreEqual <int>(1, hasErrorsChangedCount, "HasErrorsChanged count for first add");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for first add");

            collectionChangedCount = 0;
            hasErrorsChangedCount  = 0;
            propertyErrorsChangedList.Clear();

            ValidationResult vr2 = new ValidationResult("Error 2", validationResultMemberNames);

            collection.Add(vr2);

            Assert.AreEqual <int>(1, collectionChangedCount, "CollectionChanged count for second add");
            Assert.AreEqual <int>(0, hasErrorsChangedCount, "HasErrorsChanged count for second add");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for second add");

            collectionChangedCount = 0;
            hasErrorsChangedCount  = 0;
            propertyErrorsChangedList.Clear();

            collection.Remove(vr1);

            Assert.AreEqual <int>(1, collectionChangedCount, "CollectionChanged count for first remove");
            Assert.AreEqual <int>(0, hasErrorsChangedCount, "HasErrorsChanged count for first remove");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for first remove");

            collectionChangedCount = 0;
            hasErrorsChangedCount  = 0;
            propertyErrorsChangedList.Clear();

            collection.Remove(vr2);

            Assert.AreEqual <int>(1, collectionChangedCount, "CollectionChanged count for second remove");
            Assert.AreEqual <int>(1, hasErrorsChangedCount, "HasErrorsChanged count for second remove");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for second remove");
        }
        /// <summary>
        /// Verifies that the expected collection events are raised from the <see cref="ValidationResultCollection"/>
        /// for validation results with the specified member names.
        /// </summary>
        /// <param name="validationResultMemberNames">
        /// The array of member names to create validation results for that will be
        /// added and removed from the collection.
        /// </param>
        /// <param name="errorsChangedMemberNames">The array of member names to expect errors changed events for.</param>
        private static void VerifyAddRemoveCollectionEvents(string[] validationResultMemberNames, string[] errorsChangedMemberNames)
        {
            int collectionChangedCount = 0;
            int hasErrorsChangedCount = 0;
            List<string> propertyErrorsChangedList = new List<string>();

            Action collectionChanged = () => ++collectionChangedCount;
            Action hasErrorsChanged = () => ++hasErrorsChangedCount;
            Action<string> propertyErrorsChanged = propertyName => propertyErrorsChangedList.Add(propertyName);

            ValidationResultCollection collection = new TestValidationResultCollection(collectionChanged, hasErrorsChanged, propertyErrorsChanged);
            ValidationResult vr1 = new ValidationResult("Error 1", validationResultMemberNames);
            collection.Add(vr1);

            Assert.AreEqual<int>(1, collectionChangedCount, "CollectionChanged count for first add");
            Assert.AreEqual<int>(1, hasErrorsChangedCount, "HasErrorsChanged count for first add");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for first add");

            collectionChangedCount = 0;
            hasErrorsChangedCount = 0;
            propertyErrorsChangedList.Clear();

            ValidationResult vr2 = new ValidationResult("Error 2", validationResultMemberNames);
            collection.Add(vr2);

            Assert.AreEqual<int>(1, collectionChangedCount, "CollectionChanged count for second add");
            Assert.AreEqual<int>(0, hasErrorsChangedCount, "HasErrorsChanged count for second add");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for second add");

            collectionChangedCount = 0;
            hasErrorsChangedCount = 0;
            propertyErrorsChangedList.Clear();

            collection.Remove(vr1);

            Assert.AreEqual<int>(1, collectionChangedCount, "CollectionChanged count for first remove");
            Assert.AreEqual<int>(0, hasErrorsChangedCount, "HasErrorsChanged count for first remove");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for first remove");

            collectionChangedCount = 0;
            hasErrorsChangedCount = 0;
            propertyErrorsChangedList.Clear();

            collection.Remove(vr2);

            Assert.AreEqual<int>(1, collectionChangedCount, "CollectionChanged count for second remove");
            Assert.AreEqual<int>(1, hasErrorsChangedCount, "HasErrorsChanged count for second remove");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList for second remove");
        }