예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
        }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }
예제 #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);
 }