public void CollectionWithEmptyPropertyElementsPasses()
        {
            UniquePropertyCollectionValidator <ThePropertyClass> target =
                new UniquePropertyCollectionValidator <ThePropertyClass>("Property");

            List <ThePropertyClass> coll = new List <ThePropertyClass>();

            coll.Add(new ThePropertyClass(null));
            coll.Add(new ThePropertyClass(""));

            ValidationResults results = target.Validate(coll);

            Assert.IsTrue(results.IsValid);
        }
        public void CollectionWithDuplicateNamedElementsFails()
        {
            UniquePropertyCollectionValidator <ThePropertyClass> target =
                new UniquePropertyCollectionValidator <ThePropertyClass>("Property");

            List <ThePropertyClass> coll = new List <ThePropertyClass>();

            coll.Add(new ThePropertyClass("same"));
            coll.Add(new ThePropertyClass("same"));

            ValidationResults       result  = target.Validate(coll);
            List <ValidationResult> results = new List <ValidationResult>(result);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, results.Count);
        }
        public void CollectionWithDuplicateNamedElementsFailsWhenInitializedUsingAttributes()
        {
            NameValueCollection attributes = new NameValueCollection();

            attributes.Add("collectionElementUniqueIdProperty", "Property");
            UniquePropertyCollectionValidator <ThePropertyClass> target =
                new UniquePropertyCollectionValidator <ThePropertyClass>(attributes);

            List <ThePropertyClass> coll = new List <ThePropertyClass>();

            coll.Add(new ThePropertyClass("same"));
            coll.Add(new ThePropertyClass("same"));

            ValidationResults       result  = target.Validate(coll);
            List <ValidationResult> results = new List <ValidationResult>(result);

            Assert.IsFalse(result.IsValid);
            Assert.AreEqual(1, results.Count);
        }
        public void CollectionWithCaseSensitiveDuplicateNamedElementsPass()
        {
            NameValueCollection attributes = new NameValueCollection();

            attributes.Add("collectionElementUniqueIdProperty", "Property");
            attributes.Add("caseSensitive", "true");
            UniquePropertyCollectionValidator <ThePropertyClass> target =
                new UniquePropertyCollectionValidator <ThePropertyClass>(attributes);

            List <ThePropertyClass> coll = new List <ThePropertyClass>();

            coll.Add(new ThePropertyClass("Same"));
            coll.Add(new ThePropertyClass("same"));

            ValidationResults       result  = target.Validate(coll);
            List <ValidationResult> results = new List <ValidationResult>(result);

            Assert.IsTrue(result.IsValid);
            Assert.AreEqual(0, results.Count);
        }