Exemplo n.º 1
0
        public void OnEngineClosed()
        {
            VsaEngine engine = new VsaEngine();
            IVsaItems items;
            IVsaItem  item;

            engine             = new VsaEngine();
            engine.RootMoniker = "com.foo://path/to/nowhere";
            engine.Site        = new Site();

            engine.InitNew();
            items = engine.Items;
            engine.Close();

            int size;

            try {
                size = items.Count;
            } catch (VsaException e) {
                Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#1");
            }

            try {
                item = items.CreateItem("itemx", VsaItemType.Code,
                                        VsaItemFlag.Class);
            } catch (VsaException e) {
                Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#2");
            }
        }
Exemplo n.º 2
0
        private static decimal EvaluateNumericExpression(string istrExpresion)
        {
            VsaEngine engine = VsaEngine.CreateEngine();

            try
            {
                object resultado = Eval.JScriptEvaluate(istrExpresion, engine);
                return(System.Convert.ToDecimal(resultado));
            }
            catch
            {
                return(0);
            }
            engine.Close();
        }
Exemplo n.º 3
0
        private string EvalExpression(string expression)
        {
            VsaEngine engine = VsaEngine.CreateEngine();

            try
            {
                object o = Eval.JScriptEvaluate(expression, engine);
                return(System.Convert.ToDouble(o).ToString());
            }
            catch
            {
                return("No se puede evaluar la expresión");
            }
            engine.Close();
        }
Exemplo n.º 4
0
        public void IsDirtyOnEngineClosed()
        {
            VsaEngine engine = new VsaEngine();
            IVsaItems items;
            IVsaItem  item;

            engine.RootMoniker = "foo://nowhere/path";
            engine.Site        = new Site();
            engine.InitNew();

            items = engine.Items;

            item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None);
            engine.Close();

            try {
                bool dirty = item.IsDirty;
            } catch (VsaException e) {
                Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#1");
            }
        }
Exemplo n.º 5
0
        public void GetOptionOnEngineClosed()
        {
            VsaEngine engine = new VsaEngine();
            IVsaItems items;
            IVsaItem  item;

            engine.RootMoniker = "foo://nowhere/path";
            engine.Site        = new Site();
            engine.InitNew();

            items = engine.Items;

            item = items.CreateItem("item1", VsaItemType.Reference, VsaItemFlag.None);

            engine.Close();

            try {
                object opt = item.GetOption("AlwaysGenerateIL");
            } catch (VsaException e) {
                Assert.AreEqual(VsaError.EngineClosed, e.ErrorCode, "#6");
            }
        }
Exemplo n.º 6
0
    // Test the global object properties.
    public void TestEngineGlobals()
    {
        // Create a new engine instance.
        VsaEngine engine = VsaEngine.CreateEngine();

        // Get the global object.
        LenientGlobalObject global = engine.LenientGlobalObject;

        AssertNotNull("Globals (1)", global);

        // Check that the "Object" and "Function" objects
        // appear to be of the right form.
        Object objectConstructor = global.Object;

        AssertNotNull("Globals (2)", objectConstructor);
        Assert("Globals (3)", objectConstructor is ObjectConstructor);
        Object functionConstructor = global.Function;

        AssertNotNull("Globals (4)", functionConstructor);
        Assert("Globals (5)",
               functionConstructor is FunctionConstructor);

        // Check the type information.
        AssertSame("Type (1)", typeof(Boolean), global.boolean);
        AssertSame("Type (2)", typeof(Byte), global.@byte);
        AssertSame("Type (3)", typeof(SByte), global.@sbyte);
        AssertSame("Type (4)", typeof(Char), global.@char);
        AssertSame("Type (5)", typeof(Int16), global.@short);
        AssertSame("Type (6)", typeof(UInt16), global.@ushort);
        AssertSame("Type (7)", typeof(Int32), global.@int);
        AssertSame("Type (8)", typeof(UInt32), global.@uint);
        AssertSame("Type (9)", typeof(Int64), global.@long);
        AssertSame("Type (10)", typeof(UInt64), global.@ulong);
        AssertSame("Type (11)", typeof(Single), global.@float);
        AssertSame("Type (12)", typeof(Double), global.@double);
        AssertSame("Type (13)", typeof(Decimal), global.@decimal);
        AssertSame("Type (14)", typeof(Void), global.@void);

        // Check the global functions.
        CheckScriptFunction("CollectGarbage",
                            global.CollectGarbage, 0);
        CheckScriptFunction("decodeURI",
                            global.decodeURI, 1);
        CheckScriptFunction("decodeURIComponent",
                            global.decodeURIComponent, 1);
        CheckScriptFunction("encodeURI",
                            global.encodeURI, 1);
        CheckScriptFunction("encodeURIComponent",
                            global.encodeURIComponent, 1);
        CheckScriptFunction("escape",
                            global.escape, 1);
        CheckScriptFunction("eval",
                            global.eval, 1);
        CheckScriptFunction("isFinite",
                            global.isFinite, 1);
        CheckScriptFunction("isNaN",
                            global.isNaN, 1);
        CheckScriptFunction("parseFloat",
                            global.parseFloat, 1);
        CheckScriptFunction("parseInt",
                            global.parseInt, 2);
        CheckScriptFunction("ScriptEngine",
                            global.ScriptEngine, 0);
        CheckScriptFunction("ScriptEngineBuildVersion",
                            global.ScriptEngineBuildVersion, 0);
        CheckScriptFunction("ScriptEngineMajorVersion",
                            global.ScriptEngineMajorVersion, 0);
        CheckScriptFunction("ScriptEngineMinorVersion",
                            global.ScriptEngineMinorVersion, 0);
        CheckScriptFunction("unescape",
                            global.unescape, 1);

        // Check the global values.
        Assert("Value (1)",
               Double.IsPositiveInfinity((double)(global.Infinity)));
        Assert("Value (2)", Double.IsNaN((double)(global.NaN)));
        AssertNull("Value (3)", global.undefined);

        // Close the engine and exit.
        engine.Close();
    }
Exemplo n.º 7
0
 public void closeVsaEngine()
 {
     vsaEngine.Close();
 }