Esempio n. 1
0
        public void IsValidReturnsFalseWhenGivenCollectionIsNull()
        {
            IValidationRule <FakeObjectToValidate> rule = new CollectionCannotBeEmptyRule <FakeObjectToValidate, string>
                                                              (f => f.ListOfStrings, "list");

            bool isValid = rule.IsValid(new FakeObjectToValidate());

            Assert.IsFalse(isValid, "IsValid returned true for null collection.");
        }
Esempio n. 2
0
        public void GetErrorMessageReturnsMessageWhenNonNullObjectGiven()
        {
            IValidationRule <FakeObjectToValidate> rule = new CollectionCannotBeEmptyRule <FakeObjectToValidate, string>
                                                              (f => f.ListOfStrings, "list");

            string errorMessage = rule.GetErrorMessage(new FakeObjectToValidate());

            Assert.IsNotNull(errorMessage);
            Assert.IsNotEmpty(errorMessage);
        }
Esempio n. 3
0
        public void IsValidReturnsFalseForEmptyCollection()
        {
            IValidationRule <FakeObjectToValidate> rule = new CollectionCannotBeEmptyRule <FakeObjectToValidate, string>
                                                              (f => f.ListOfStrings, "list");

            bool isValid = rule.IsValid(new FakeObjectToValidate {
                ListOfStrings = new List <string>()
            });

            Assert.IsFalse(isValid, "IsValid returned false for empty collection.");
        }
Esempio n. 4
0
        public void IsValidReturnsTrueForCollectionThatIsNotEmpty()
        {
            IValidationRule <FakeObjectToValidate> rule = new CollectionCannotBeEmptyRule <FakeObjectToValidate, string>
                                                              (f => f.ListOfStrings, "list");

            bool isValid = rule.IsValid(new FakeObjectToValidate {
                ListOfStrings = new List <string> {
                    "3"
                }
            });

            Assert.IsTrue(isValid, "IsValid returned false for non-empty collection.");
        }