public void ValidatePath_ValidValidator_ValidatePathIsCalled()
        {
            ILinkerView view = MockRepository.GenerateMock<ILinkerView>();
            IPathValidation validator = MockRepository.GenerateMock<IPathValidation>();
            ValidationArgs args = new ValidationArgs("test");

            MainController controller = new MainController(view, validator, null, null, null);

            controller.ValidatePath(view, args);

            validator.AssertWasCalled(v => v.ValidPath(Arg<String>.Matches(s => s.Equals("test")), out Arg<String>.Out("").Dummy));
        }
 public void ValidatePath(object sender, ValidationArgs e)
 {
     String errorMessage;
     if (_pathValidator.ValidPath(e.PathToValidate, out errorMessage))
     {
         e.Valid = true;
     }
     else
     {
         e.Valid = false;
         e.ErrorMessge = errorMessage;
     }
 }
Example #3
0
 /// <summary>
 /// Triggers the ValidatePath event.
 /// </summary>
 public virtual void CallValidatePath(ValidationArgs ea)
 {
     if (m_ValidatePath != null)
         m_ValidatePath(this, ea);
 }
Example #4
0
        private Boolean ValidateEditor(TextBox textBox)
        {
            var validEA = new ValidationArgs(textBox.Text);
            CallValidatePath(validEA);

            if (!validEA.Valid)
            {
                ErrorProvider.SetError(textBox, "Please enter a valid path");
                textBox.TextChanged += RealTimeValidation;
            }
            else
            {
                ErrorProvider.SetError(textBox, String.Empty);
                textBox.TextChanged -= RealTimeValidation;
            }

            return validEA.Valid;
        }