Ejemplo n.º 1
0
        public void Test_all_distributed_extension_scripts()
        {
            ScriptManifestValidator validator = new ScriptManifestValidator();
            StringBuilder           errors    = new StringBuilder();

            string[] scripts = Directory.GetFiles(_scriptRoot, "*.xml");
            if (scripts == null || scripts.Length == 0)
            {
                Assert.Fail("No scripts found at " + _scriptRoot);
            }
            foreach (string scriptPath in scripts)
            {
                if (scriptPath.EndsWithInvariantIgnoreCase("script-template.xml"))
                {
                    continue;
                }
                ScriptManifestValidationResult result = validator.Validate(scriptPath);
                if (result.IsInvalid)
                {
                    errors.AppendFormat(" - {0}: {1}\r\n",
                                        Path.GetFileNameWithoutExtension(scriptPath),
                                        result.ValidationErrors);
                }
            }
            if (errors.Length > 0)
            {
                errors.Insert(0, "The following scripts failed validation:\r\n");
                Assert.Fail(errors.ToString());
            }
        }
Ejemplo n.º 2
0
        public void Validator_should_return_a_valid_result()
        {
            ScriptManifestValidator validator = new ScriptManifestValidator();
            string scriptPath = Environment.CurrentDirectory + @"\ScriptTests\ExtensionTests.xml";
            ScriptManifestValidationResult result = validator.Validate(scriptPath);

            Assert.IsFalse(result.IsInvalid);
        }
        public void Validate_extension_and_execute_expression() {
            // validate the script first
            ScriptManifestValidator validator = new ScriptManifestValidator();
            string scriptPath = Environment.CurrentDirectory + @"\ScriptTests\ExtensionTests.xml";
            ScriptManifestValidationResult result = validator.Validate(scriptPath);
            Assert.IsFalse(result.IsInvalid);

            // now execute a function against it
            ScriptTestHarness harness = new ScriptTestHarness();
            harness.LoadExtension(scriptPath);
            string executionResult = harness.Execute("test.Hello()");
            Assert.AreEqual(@"""hi""", executionResult);
        }
Ejemplo n.º 4
0
        public void Validate_extension_and_execute_expression()
        {
            // validate the script first
            ScriptManifestValidator validator = new ScriptManifestValidator();
            string scriptPath = Environment.CurrentDirectory + @"\ScriptTests\ExtensionTests.xml";
            ScriptManifestValidationResult result = validator.Validate(scriptPath);

            Assert.IsFalse(result.IsInvalid);

            // now execute a function against it
            ScriptTestHarness harness = new ScriptTestHarness();

            harness.LoadExtension(scriptPath);
            string executionResult = harness.Execute("test.Hello()");

            Assert.AreEqual(@"""hi""", executionResult);
        }
 public void Test_all_distributed_extension_scripts() {
     ScriptManifestValidator validator = new ScriptManifestValidator();
     StringBuilder errors = new StringBuilder();
     string[] scripts = Directory.GetFiles(_scriptRoot, "*.xml");
     if(scripts == null || scripts.Length == 0) {
         Assert.Fail("No scripts found at " + _scriptRoot);
     }
     foreach(string scriptPath in scripts) {
         if(scriptPath.EndsWithInvariantIgnoreCase("script-template.xml")) {
             continue;
         }
         ScriptManifestValidationResult result = validator.Validate(scriptPath);
         if(result.IsInvalid) {
             errors.AppendFormat(" - {0}: {1}\r\n",
                                 Path.GetFileNameWithoutExtension(scriptPath),
                                 result.ValidationErrors);
         }
     }
     if(errors.Length > 0) {
         errors.Insert(0, "The following scripts failed validation:\r\n");
         Assert.Fail(errors.ToString());
     }
 }
 public void Validator_should_return_a_valid_result() {
     ScriptManifestValidator validator = new ScriptManifestValidator();
     string scriptPath = Environment.CurrentDirectory + @"\ScriptTests\ExtensionTests.xml";
     ScriptManifestValidationResult result = validator.Validate(scriptPath);
     Assert.IsFalse(result.IsInvalid);
 }