Example #1
0
        public JSTestRunner(string initSnapshotName, IDictionary <string, string> planArguments, IJSTestProvider provider)
        {
            this.ctx              = Context.enter();
            this.provider         = provider;
            this.initSnapshotName = initSnapshotName;
            var tests = provider.GetTestDrivers().SelectMany(d =>
                                                             d.Tests.Select(t => new { Driver = d, Name = t }));

            this.planArguments = planArguments;

            MachineInitFunc initFunc = PossiblyInitializeMachine;

            this.scope = ctx.initStandardObjects();
            foreach (var thisTest in tests)
            {
                var      test = thisTest;
                TestFunc func = delegate(IMachine machine, IDictionary <string, string> arguments, ITestResultBin bin)
                {
                    return(test.Driver.RunTest(test.Name, machine, bin, arguments));
                };

                scope.defineProperty(test.Name, new CallableTest(func, initFunc, planArguments, provider), ScriptableObject.READONLY + ScriptableObject.PERMANENT);
            }

            var jsArgsObject = ctx.newObject(scope);

            foreach (var arg in planArguments)
            {
                jsArgsObject.put(arg.Key, jsArgsObject, arg.Value);
            }

            foreach (var name in new[] { "args", "Args", "ARGS" })
            {
                scope.defineProperty(name, jsArgsObject, ScriptableObject.READONLY + ScriptableObject.PERMANENT);
            }

            scope.defineProperty("Debug", new DebugFunction(), ScriptableObject.READONLY + ScriptableObject.PERMANENT);

            ssFunc = new SnapshotFunction(initFunc, provider);

            scope.defineProperty("Snapshot", ssFunc, ScriptableObject.READONLY + ScriptableObject.PERMANENT);
        }
Example #2
0
        public JSTestRunner(string initSnapshotName, IDictionary<string, string> planArguments, IJSTestProvider provider)
        {
            this.ctx = Context.enter ();
            this.provider = provider;
            this.initSnapshotName = initSnapshotName;
            var tests = provider.GetTestDrivers().SelectMany(d =>
                                               d.Tests.Select (t => new { Driver = d, Name = t}));

            this.planArguments = planArguments;

            MachineInitFunc initFunc = PossiblyInitializeMachine;

            this.scope = ctx.initStandardObjects();
            foreach(var thisTest in tests)
            {
                var test = thisTest;
                TestFunc func = delegate(IMachine machine, IDictionary<string, string> arguments, ITestResultBin bin)
                {
                    return test.Driver.RunTest(test.Name, machine, bin, arguments);
                };

                scope.defineProperty(test.Name, new CallableTest(func, initFunc, planArguments, provider), ScriptableObject.READONLY + ScriptableObject.PERMANENT);
            }

            var jsArgsObject = ctx.newObject(scope);
            foreach(var arg in planArguments)
            {
                jsArgsObject.put (arg.Key, jsArgsObject, arg.Value);
            }

            foreach(var name in new[] { "args", "Args", "ARGS"})
            {
                scope.defineProperty(name, jsArgsObject, ScriptableObject.READONLY + ScriptableObject.PERMANENT);
            }

            scope.defineProperty("Debug", new DebugFunction(), ScriptableObject.READONLY + ScriptableObject.PERMANENT);

            ssFunc = new SnapshotFunction(initFunc, provider);

            scope.defineProperty("Snapshot", ssFunc, ScriptableObject.READONLY + ScriptableObject.PERMANENT);
        }