public void ClearRaisesEvents()
        {
            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);

            collection.Add(new ValidationResult("Property Error", new string[] { "Member" }));
            collection.Add(new ValidationResult("Entity Error", null));

            string[] errorsChangedMemberNames = new string[] { "Member", null };

            Assert.AreEqual <int>(2, collectionChangedCount, "collectionChangedCount after adding");
            Assert.AreEqual <int>(1, hasErrorsChangedCount, "hasErrorsChangedCount after adding");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList after adding");

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

            collection.Clear();

            // We only get one collection changed event because it's an atomic action
            Assert.AreEqual <int>(1, collectionChangedCount, "collectionChangedCount after clearing");
            Assert.AreEqual <int>(1, hasErrorsChangedCount, "hasErrorsChangedCount after clearing");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList after clearing");
        }
        public void ClearRaisesEvents()
        {
            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);
            collection.Add(new ValidationResult("Property Error", new string[] { "Member" }));
            collection.Add(new ValidationResult("Entity Error", null));

            string[] errorsChangedMemberNames = new string[] { "Member", null };

            Assert.AreEqual<int>(2, collectionChangedCount, "collectionChangedCount after adding");
            Assert.AreEqual<int>(1, hasErrorsChangedCount, "hasErrorsChangedCount after adding");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList after adding");

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

            collection.Clear();

            // We only get one collection changed event because it's an atomic action
            Assert.AreEqual<int>(1, collectionChangedCount, "collectionChangedCount after clearing");
            Assert.AreEqual<int>(1, hasErrorsChangedCount, "hasErrorsChangedCount after clearing");
            Assert.IsTrue(propertyErrorsChangedList.OrderBy(s => s).SequenceEqual(errorsChangedMemberNames.OrderBy(s => s)), "propertyErrorsChangedList after clearing");
        }