Example #1
0
        private dynamic Require(string fromModule, string moduleName)
        {
            var definition = _packageSystem.GetDefinition(fromModule, moduleName);

            if (definition == null)
            {
                LoadScript(_referenceResolver.Resolve(fromModule, moduleName));

                definition = _packageSystem.GetDefinition(fromModule, moduleName);
            }

            if (definition != null)
            {
                return(definition());
            }

            return(null);
        }
        public ITestCollection DefineTests(IPackageSystem packageSystem, IScript script)
        {
            using (var engine = _runtimeFactory.GetRuntime())
            {
                var collection = _reflector.Reflect(script, engine);

                foreach (var framework in _frameworks.Where(framework => framework.Framework != Framework.Jasmine)) // reflector is jasmine impl
                {
                    framework.Install(script, engine);
                }

                engine.Execute(script.Content);

                // Execute the primary define() from the file, if it exists
                var package = packageSystem.GetDefinition(null, script.Module.ModuleName);
                package?.Invoke();

                return collection;
            }
        }
        public ITestCollection DefineTests(IPackageSystem packageSystem, IScript script)
        {
            using (var engine = _runtimeFactory.GetRuntime())
            {
                var collection = _reflector.Reflect(script, engine);

                foreach (var framework in _frameworks.Where(framework => framework.Framework != Framework.Jasmine)) // reflector is jasmine impl
                {
                    framework.Install(script, engine);
                }

                engine.Execute(script.Content);

                // Execute the primary define() from the file, if it exists
                var package = packageSystem.GetDefinition(null, script.Module.ModuleName);
                package?.Invoke();

                return(collection);
            }
        }