Esempio n. 1
0
 public ValidationResult Validate(Input input)
 {
     var isValid = true;
     if (String.IsNullOrWhiteSpace(input.Name)) isValid = false;
     if (input.Age == -1) isValid = false;
     if (input.HasCheezburger)
     {
         if (input.Cheezburger == null) isValid = false;
     }
     return new ValidationResult(isValid);
 }
        public void Validate_with_input_with_null_Name_must_be_invalid()
        {
            // Arrange
            var invalidInput = new Input { Name = null };
            var sut = MakeSUT();

            // Act
            var validationResult = sut.Validate(invalidInput);

            // Assert
            AssertIsInvalid(validationResult, "input with null Name should be invalid");
        }
        public void Validate_with_input_with_Age_minus_one_must_be_invalid()
        {
            // Arrange
            var invalidInput = new Input { Name = "someName", Age = -1 };
            var sut = MakeSUT();

            // Act
            var validationResult = sut.Validate(invalidInput);

            // Assert
            AssertIsInvalid(validationResult, "input with Age -1 should be invalid");
        }