Example #1
0
        public void ReturnValidIfModelValid()
        {
            var model             = GetValidModel();
            var validationResults = StaticTestHelpers.GetValidationResults(model);

            Assert.Empty(validationResults);
        }
Example #2
0
 public void ReturnInvalidIfNameMissing()
 {
     var model = GetValidModel();
     model.Name = null;
     var validationResults = StaticTestHelpers.GetValidationResults(model);
     Assert.Contains(validationResults, validationResult => validationResult.MemberNames.Contains("Name") && validationResult.ErrorMessage.ToLower().Contains("required"));
 }
Example #3
0
 public void ReturnInvalidIfNameTooShort()
 {
     var model = GetValidModel();
     model.Name = StaticTestHelpers.GetRandomString(2);
     var validationResults = StaticTestHelpers.GetValidationResults(model);
     Assert.Contains(validationResults, validationResult => validationResult.MemberNames.Contains("Name") && validationResult.ErrorMessage.ToLower().Contains("min"));
 }
Example #4
0
        public void ReturnInvalidIfDescriptionTooLong()
        {
            var model = GetValidModel();

            model.Description = StaticTestHelpers.GetRandomString(1000);
            var validationResults = StaticTestHelpers.GetValidationResults(model);

            Assert.Contains(validationResults, validationResult => validationResult.MemberNames.Contains("Description") && validationResult.ErrorMessage.ToLower().Contains("max"));
        }
        public void ReturnValidIfDescriptionEmpty()
        {
            var model = GetValidModel();

            model.Description = String.Empty;
            var validationResults = StaticTestHelpers.GetValidationResults(model);

            Assert.Empty(validationResults);
        }