public void BuildWithDependency(string functionFileName)
        {
            // Compile
            var environment = EnvironmentManager.CreateEnvironment(BASE_PATH, functionFileName);

            var functionFile = environment.FunctionFile;
            var projectFile  = environment.ProjectFile;
            var assemblyFile = environment.AssemblyFile;

            var restorer = new DependencyRestorer(environment);

            restorer.CopyAndRestore();

            var compiler = new DefaultCompiler(new DefaultParser(), new WithDependencyReferencesManager());
            var function = FunctionCreator.CreateFunction(functionFile, projectFile);

            compiler.Compile(function);

            // Invoke
            var invoker = new DefaultInvoker();

            var args = WebManager.GetHttpRequest();

            object result = invoker.Execute(function, args);
        }
Exemple #2
0
        public void BuildWithDependency(string functionFileName)
        {
            var environment = EnvironmentManager.CreateEnvironment(BASE_PATH, functionFileName);

            var functionFile = environment.FunctionFile;
            var projectFile  = environment.ProjectFile;
            var assemblyFile = environment.AssemblyFile;

            Assert.True(File.Exists(functionFile));
            Assert.True(File.Exists(projectFile));
            Assert.False(File.Exists(assemblyFile));

            var restorer = new DependencyRestorer(environment);

            restorer.CopyAndRestore();

            var compiler = new DefaultCompiler(new DefaultParser(), new WithDependencyReferencesManager());
            var function = FunctionCreator.CreateFunction(functionFile, projectFile);

            Assert.False(function.IsCompiled());

            compiler.Compile(function);

            Assert.True(function.IsCompiled());

            Assert.True(File.Exists(assemblyFile));
            Assert.NotEmpty(File.ReadAllBytes(assemblyFile));
        }
        private static IFunction GetCompiledFunctionWithDepedencies(string functionFileName)
        {
            // Creates Environment
            var environment = EnvironmentManager.CreateEnvironment(BASE_PATH, functionFileName);

            var functionFile = environment.FunctionFile;
            var projectFile  = environment.ProjectFile;
            var assemblyFile = environment.AssemblyFile;

            // Restore Dependencies
            var restorer = new DependencyRestorer(environment);

            restorer.CopyAndRestore();

            // Compile
            var compiler = new DefaultCompiler(new DefaultParser(), new WithDependencyReferencesManager());
            var function = FunctionCreator.CreateFunction(functionFile, projectFile);

            compiler.Compile(function);

            return(function);
        }