Example #1
0
        public void ActivityDTO_ValidateRules_NullRuleSet_ReturnsTrue()
        {
            //------------Setup for test--------------------------
            var activityDTO = new ActivityDTO();
            //------------Execute Test---------------------------
            var validate = activityDTO.Validate("FieldName", (IRuleSet)null);

            //------------Assert Results-------------------------
            Assert.IsTrue(validate);
        }
Example #2
0
        public void ActivityDTO_Validate_GivenNoRules_ReturnTrue()
        {
            //------------Setup for test--------------------------
            var activityDTO = new ActivityDTO();
            //------------Execute Test---------------------------
            var isValid = activityDTO.Validate("FieldName", new RuleSet());

            //------------Assert Results-------------------------
            Assert.IsTrue(isValid);
        }
Example #3
0
        public void ActivityDTO_FieldName_ValidatesForErrors_ReturnsError()
        {
            //------------Setup for test--------------------------
            var activityDTO = new ActivityDTO();

            activityDTO.FieldName = "1";
            //------------Execute Test---------------------------
            activityDTO.Validate(() => activityDTO.FieldName, "");
            //------------Assert Results-------------------------
            Assert.AreEqual(1, activityDTO.Errors.Count);
        }
Example #4
0
        public void ActivityDTO_Validate_Executed_SetErrorsProperty()
        {
            //------------Setup for test--------------------------
            var activityDTO = new ActivityDTO {
                FieldName = null
            };
            var ruleSet = new RuleSet();

            ruleSet.Add(new IsNullRule(() => activityDTO.FieldName));
            //------------Execute Test---------------------------
            activityDTO.Validate("FieldName", ruleSet);
            //------------Assert Results-------------------------
            Assert.AreEqual(1, activityDTO.Errors.Count);
        }
Example #5
0
        public void ActivityDTO_Validate_GivenRules_HasPassingRuleReturnTrue()
        {
            //------------Setup for test--------------------------
            var activityDTO = new ActivityDTO {
                FieldName = "FeildName"
            };
            var ruleSet = new RuleSet();

            ruleSet.Add(new IsNullRule(() => activityDTO.FieldName));
            //------------Execute Test---------------------------
            var isValid = activityDTO.Validate("FieldName", ruleSet);

            //------------Assert Results-------------------------
            Assert.IsTrue(isValid);
        }
Example #6
0
 public void ActivityDTO_FieldName_ValidatesForErrors_ReturnsError()
 {
     //------------Setup for test--------------------------
     var activityDTO = new ActivityDTO();
     activityDTO.FieldName = "1";
     //------------Execute Test---------------------------
     activityDTO.Validate(() => activityDTO.FieldName, "");
     //------------Assert Results-------------------------
     Assert.AreEqual(1, activityDTO.Errors.Count);
 }
Example #7
0
 public void ActivityDTO_Validate_Executed_SetErrorsProperty()
 {
     //------------Setup for test--------------------------
     var activityDTO = new ActivityDTO { FieldName = null };
     var ruleSet = new RuleSet();
     ruleSet.Add(new IsNullRule(() => activityDTO.FieldName));
     //------------Execute Test---------------------------
     activityDTO.Validate("FieldName", ruleSet);
     //------------Assert Results-------------------------
     Assert.AreEqual(1, activityDTO.Errors.Count);
 }
Example #8
0
 public void ActivityDTO_Validate_GivenRules_HasPassingRuleReturnTrue()
 {
     //------------Setup for test--------------------------
     var activityDTO = new ActivityDTO { FieldName = "FeildName" };
     var ruleSet = new RuleSet();
     ruleSet.Add(new IsNullRule(() => activityDTO.FieldName));
     //------------Execute Test---------------------------
     bool isValid = activityDTO.Validate("FieldName", ruleSet);
     //------------Assert Results-------------------------
     Assert.IsTrue(isValid);
 }
Example #9
0
 public void ActivityDTO_Validate_GivenNoRules_ReturnTrue()
 {
     //------------Setup for test--------------------------
     var activityDTO = new ActivityDTO();
     //------------Execute Test---------------------------
     bool isValid = activityDTO.Validate("FieldName", new RuleSet());
     //------------Assert Results-------------------------
     Assert.IsTrue(isValid);
 }
Example #10
0
 public void ActivityDTO_ValidateRules_NullRuleSet_ReturnsTrue()
 {
     //------------Setup for test--------------------------
     var activityDTO = new ActivityDTO();
     //------------Execute Test---------------------------
     var validate = activityDTO.Validate("FieldName", (IRuleSet)null);
     //------------Assert Results-------------------------
     Assert.IsTrue(validate);
 }