Exemplo n.º 1
0
        public virtual void TestValidExternals()
        {
            SimpleBindings bindings = new SimpleBindings();

            bindings.Add(new SortField("valid0", SortFieldType.INT32));
            bindings.Add(new SortField("valid1", SortFieldType.INT32));
            bindings.Add(new SortField("valid2", SortFieldType.INT32));
            bindings.Add(new SortField("_score", SortFieldType.SCORE));
            bindings.Add("valide0", JavascriptCompiler.Compile("valid0 - valid1 + valid2 + _score"
                                                               ));
            bindings.Validate();
            bindings.Add("valide1", JavascriptCompiler.Compile("valide0 + valid0"));
            bindings.Validate();
            bindings.Add("valide2", JavascriptCompiler.Compile("valide0 * valide1"));
            bindings.Validate();
        }
Exemplo n.º 2
0
        public virtual void TestSelfRecursion()
        {
            SimpleBindings bindings = new SimpleBindings();

            bindings.Add("cycle0", JavascriptCompiler.Compile("cycle0"));
            try
            {
                bindings.Validate();
                Assert.Fail("didn't get expected exception");
            }
            catch (ArgumentException expected)
            {
                Assert.IsTrue(expected.Message.Contains("Cycle detected"));
            }
        }
 public virtual void TestCoRecursion()
 {
     SimpleBindings bindings = new SimpleBindings();
     bindings.Add("cycle0", JavascriptCompiler.Compile("cycle1"));
     bindings.Add("cycle1", JavascriptCompiler.Compile("cycle0"));
     try
     {
         bindings.Validate();
         Fail("didn't get expected exception");
     }
     catch (ArgumentException expected)
     {
         IsTrue(expected.Message.Contains("Cycle detected"));
     }
 }
Exemplo n.º 4
0
        public virtual void TestInvalidExternal2()
        {
            SimpleBindings bindings = new SimpleBindings();

            bindings.Add(new SortField("valid", SortFieldType.INT32));
            bindings.Add("invalid", JavascriptCompiler.Compile("valid + badreference"));
            try
            {
                bindings.Validate();
                Assert.Fail("didn't get expected exception");
            }
            catch (ArgumentException expected)
            {
                Assert.IsTrue(expected.Message.Contains("Invalid reference"));
            }
        }
        public virtual void TestCoRecursion4()
        {
            SimpleBindings bindings = new SimpleBindings();

            bindings.Add("cycle0", JavascriptCompiler.Compile("100"));
            bindings.Add("cycle1", JavascriptCompiler.Compile("100"));
            bindings.Add("cycle2", JavascriptCompiler.Compile("cycle1 + cycle0 + cycle3"));
            bindings.Add("cycle3", JavascriptCompiler.Compile("cycle0 + cycle1 + cycle2"));
            try
            {
                bindings.Validate();
                Fail("didn't get expected exception");
            }
            catch (ArgumentException expected)
            {
                IsTrue(expected.Message.Contains("Cycle detected"));
            }
        }
 public virtual void TestInvalidExternal()
 {
     SimpleBindings bindings = new SimpleBindings();
     bindings.Add(new SortField("valid", SortField.Type_e.INT));
     bindings.Add("invalid", JavascriptCompiler.Compile("badreference"));
     try
     {
         bindings.Validate();
         Fail("didn't get expected exception");
     }
     catch (ArgumentException expected)
     {
         IsTrue(expected.Message.Contains("Invalid reference"));
     }
 }
 public virtual void TestValidExternals()
 {
     SimpleBindings bindings = new SimpleBindings();
     bindings.Add(new SortField("valid0", SortField.Type_e.INT));
     bindings.Add(new SortField("valid1", SortField.Type_e.INT));
     bindings.Add(new SortField("valid2", SortField.Type_e.INT));
     bindings.Add(new SortField("_score", SortField.Type_e.SCORE));
     bindings.Add("valide0", JavascriptCompiler.Compile("valid0 - valid1 + valid2 + _score"
         ));
     bindings.Validate();
     bindings.Add("valide1", JavascriptCompiler.Compile("valide0 + valid0"));
     bindings.Validate();
     bindings.Add("valide2", JavascriptCompiler.Compile("valide0 * valide1"));
     bindings.Validate();
 }