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)); }
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); }
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)); }
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); }