Esempio n. 1
0
        public void RuleUsesSuppliedComparer()
        {
            var candidate = new DistinctCollectionValuesRule <TestItem, string>(x => x.Value, StringComparer.InvariantCultureIgnoreCase);

            Assert.IsFalse(candidate.IsValid(this.CreateItems(new[] { "John", "Paul", "George", "Ringo", "john" })));
            Assert.AreEqual(candidate.Message, "The list of items contains duplicate values");
        }
Esempio n. 2
0
        public void RuleWorksWithOurConfigurationCollections()
        {
            var candidate = new DistinctCollectionValuesRule <NamedConfigElement, string>(x => x.Name, StringComparer.InvariantCultureIgnoreCase);

            Assert.IsFalse(candidate.IsValid(new NamedConfigElementCollection <NamedConfigElement> {
                new NamedConfigElement {
                    Name = "John"
                }, new NamedConfigElement {
                    Name = "john"
                }
            }));
            Assert.AreEqual(candidate.Message, "The list of items contains duplicate values");
        }
 public void RuleWorksWithOurConfigurationCollections()
 {
     var candidate = new DistinctCollectionValuesRule<NamedConfigElement, string>(x => x.Name, StringComparer.InvariantCultureIgnoreCase);
     Assert.IsFalse(candidate.IsValid(new NamedConfigElementCollection<NamedConfigElement> { new NamedConfigElement { Name = "John"}, new NamedConfigElement { Name = "john"} }));
     Assert.AreEqual(candidate.Message, "The list of items contains duplicate values");
 }
 public void RuleUsesSuppliedComparer()
 {
     var candidate = new DistinctCollectionValuesRule<TestItem, string>(x => x.Value, StringComparer.InvariantCultureIgnoreCase);
     Assert.IsFalse(candidate.IsValid(this.CreateItems(new[] { "John", "Paul", "George", "Ringo", "john" })));
     Assert.AreEqual(candidate.Message, "The list of items contains duplicate values");
 }
 public void RuleIsNotValidForDuplicateList()
 {
     var candidate = new DistinctCollectionValuesRule<TestItem, string>(x => x.Value, null);
     Assert.IsFalse(candidate.IsValid(this.CreateItems(new[] { "John", "Paul", "George", "Ringo", "John" })));
 }
 public void RuleIsValidForEmptyList()
 {
     var candidate = new DistinctCollectionValuesRule<TestItem, string>(x => x.Value, null);
     Assert.IsTrue(candidate.IsValid(new List<TestItem>()));
 }
Esempio n. 7
0
        public void RuleIsNotValidForDuplicateList()
        {
            var candidate = new DistinctCollectionValuesRule <TestItem, string>(x => x.Value, null);

            Assert.IsFalse(candidate.IsValid(this.CreateItems(new[] { "John", "Paul", "George", "Ringo", "John" })));
        }
Esempio n. 8
0
        public void RuleIsValidForEmptyList()
        {
            var candidate = new DistinctCollectionValuesRule <TestItem, string>(x => x.Value, null);

            Assert.IsTrue(candidate.IsValid(new List <TestItem>()));
        }