コード例 #1
0
        public object call(Context c, Scriptable s1, Scriptable s2, object[] objarr)
        {
            IDictionary <string, object> testParams = new Dictionary <string, object>();

            IMachine machine = null;

            string testKey = DEFAULT_TESTKEY;

            // Initialize test arguments with plan arguments.
            foreach (var arg in planArguments)
            {
                testParams[arg.Key] = arg.Value;
            }


            // Override above with user arguments
            if (objarr.Length > 0)
            {
                IdScriptableObject sObj = objarr[0] as IdScriptableObject;

                if (sObj != null)
                {
                    foreach (object id in sObj.getIds())
                    {
                        object value = sObj.get(id);
                        testParams[id.ToString()] = value;
                    }
                }
            }

            // Find magic arguments
            foreach (var parm in testParams)
            {
                object value = parm.Value;

                switch (parm.Key)
                {
                case ARG_TESTKEY:
                    testKey = value.ToString();
                    break;

                case ARG_MACHINE:
                    machine = new MachineResolver(provider).Resolve(value);
                    break;
                }
            }

            if (machine == null)
            {
                throw new Exception("Test requires '" + ARG_MACHINE + "' argument");
            }

            var stringParams = testParams.ToDictionary(e => e.Key, e => e.Value.ToString());

            return(Context.javaToJS(InvokeTest(machine, testKey, stringParams), s1));
        }
コード例 #2
0
        public object call(Context c, Scriptable scope, Scriptable thisObj, object[] objarr)
        {
            if(objarr.Length < 1)
            {
                throw new Exception("Snapshot function requires machine argument");
            }

            IMachine machine = new MachineResolver(provider).Resolve(objarr[0]);

            initFunc(machine);

            var snapshotId = machine.MakeSnapshot();

            // We need to clean up the snapshots at some point.
            Action oldAction = CleanupSnapshots;
            CleanupSnapshots = () =>
            {
                machine.DeleteSnapshot(snapshotId);
                oldAction();
            };

            return new SnapshotObject(machine, snapshotId);
        }
コード例 #3
0
        public object call(Context c, Scriptable scope, Scriptable thisObj, object[] objarr)
        {
            if (objarr.Length < 1)
            {
                throw new Exception("Snapshot function requires machine argument");
            }

            IMachine machine = new MachineResolver(provider).Resolve(objarr[0]);

            initFunc(machine);

            var snapshotId = machine.MakeSnapshot();

            // We need to clean up the snapshots at some point.
            Action oldAction = CleanupSnapshots;

            CleanupSnapshots = () =>
            {
                machine.DeleteSnapshot(snapshotId);
                oldAction();
            };

            return(new SnapshotObject(machine, snapshotId));
        }
コード例 #4
0
ファイル: CallableTest.cs プロジェクト: bizarrefish/TestVisor
        public object call(Context c, Scriptable s1, Scriptable s2, object[] objarr)
        {
            IDictionary<string, object> testParams = new Dictionary<string, object>();

            IMachine machine = null;

            string testKey = DEFAULT_TESTKEY;

            // Initialize test arguments with plan arguments.
            foreach(var arg in planArguments)
            {
                testParams[arg.Key] = arg.Value;
            }

            // Override above with user arguments
            if(objarr.Length > 0)
            {
                IdScriptableObject sObj = objarr[0] as IdScriptableObject;

                if(sObj != null)
                {
                    foreach(object id in sObj.getIds())
                    {
                        object value = sObj.get (id);
                        testParams[id.ToString()] = value;
                    }
                }
            }

            // Find magic arguments
            foreach(var parm in testParams)
            {
                object value = parm.Value;

                switch(parm.Key)
                {
                case ARG_TESTKEY:
                    testKey = value.ToString();
                    break;

                case ARG_MACHINE:
                    machine = new MachineResolver(provider).Resolve(value);
                    break;
                }
            }

            if(machine == null)
            {
                throw new Exception("Test requires '" + ARG_MACHINE + "' argument");
            }

            var stringParams = testParams.ToDictionary(e => e.Key, e => e.Value.ToString());

            return Context.javaToJS(InvokeTest (machine, testKey, stringParams), s1);
        }