public void Validate() { DefaultValidator v = new DefaultValidator(); v.Validate(5); v.Validate(5.4); v.Validate("hi there"); v.Validate(v); }
public void TestDefaultValidatorValidatesCharactersAllAllowed() { var validator = new DefaultValidator { IllegalCharacters = new[] { 'a' } }; var fileToTest = new ImportFile { Name = "b.xml" }; var result = validator.Validate(fileToTest); Assert.IsTrue(result.IsValid); }
public void TestDefaultValidatorValidatesFileNameLengthEqualToMax() { var validator = new DefaultValidator { MaximumFileNameLength = 5 }; var fileToTest = new ImportFile { Name = "e.xml" }; var result = validator.Validate(fileToTest); Assert.IsTrue(result.IsValid); }
public void TestValidatorDefaults() { var validator = new DefaultValidator(); var fileToTest = new ImportFile { Name = "test.xml", Size = 0 }; var result = validator.Validate(fileToTest); Assert.IsTrue(result.IsValid); }
public void TestDefaultValidatorValidatesInvalidExtension() { var validator = new DefaultValidator(); validator.BlockedFileExtensions.Add(".xml"); var fileToTest = new ImportFile { Name = "test.xml", }; var result = validator.Validate(fileToTest); Assert.IsFalse(result.IsValid); }
public void TestDefaultValidatorValidatesCharacters() { var validator = new DefaultValidator { IllegalCharacters = new[] { 'a' } }; var fileToTest = new ImportFile { Name = "a.xml" }; var result = validator.Validate(fileToTest); Assert.IsTrue(result.IsValid); Assert.That(result.Warnings.Count == 1); }
public void TestDefaultValidatorValidatesFileNameLengthTooLong() { var validator = new DefaultValidator { MaximumFileNameLength = 120 }; var fileToTest = new ImportFile { Name = new string('a', 120) + ".xml" }; var result = validator.Validate(fileToTest); Assert.IsTrue(result.IsValid); Assert.That(result.Warnings.Count == 1); }
public void TestDefaultValidatorValidatesSmallerFileSize() { var size = 120; var validator = new DefaultValidator { MaximumFileSize = size }; var fileToTest = new ImportFile { Name = "test.xml", Size = size - 1 }; var result = validator.Validate(fileToTest); Assert.IsTrue(result.IsValid); }
/// <summary> /// Validacia s default validatorom a defaultnym setom pravidiel /// </summary> /// <param name="path"></param> private void Validate(string path) { Log("Reading input file.. "); var kv = KVDPH.LoadFromFile(path); LogLn("OK", false); Log("Creating validation rules set.. "); var rules = new DefaultValidationSetFactory().ValidationSet; LogLn("OK", false); LogLn("Number of rules: " + rules.Count); LogLn("Validating.."); var validator = new DefaultValidator(); validator.AddObserver(this); var result = validator.Validate(kv, rules); LogLn("Validating completed."); if (result.Count == 0) { LogLn("Validation passed with no problems or warnings."); return; } else { LogLn("Number of problems: " + result.Count); foreach (var problem in result) HandleProblem(problem); Log(Environment.NewLine, false); } }