HasDependencies() public method

public HasDependencies ( ) : bool
return bool
コード例 #1
0
        public Page GenerateFrom(Harness harness)
        {
            var page = new Page();

            var harnessView = (HarnessView)_engine.CreateInstance(_descriptor);
            harnessView.Harness = harness;
            harnessView.FrameworkScript = harness.Framework.ScriptName;
            harnessView.FrameworkExecutionScript = harness.Framework.ExecuteScriptName;
            harnessView.FrameworkReportingScript = harness.Framework.ReportScriptName;

            page.RootPath = Path.GetTempPath() + @"Forseti/";
            page.Filename = string.Format("{0}runner.html", page.RootPath);

            if (!Directory.Exists(page.RootPath))
                Directory.CreateDirectory(page.RootPath);

            if (harness.HasDependencies())
            {
                var actualDependencies = new List<string>();
                foreach (var dependency in harness.Dependencies)
                {
                    CopyScript(page.RootPath, dependency.RelativePath);
                    actualDependencies.Add(dependency.RelativePath);
                }
                harnessView.Dependencies = actualDependencies.ToArray();
            } else {
				harnessView.Dependencies = new string[0];
			}
							

            var writer = new StringWriter();
            harnessView.RenderView(writer);

            var result = writer.ToString();

            File.WriteAllText(page.RootPath + harness.Framework.ScriptName, harness.Framework.Script);
            File.WriteAllText(page.RootPath + harness.Framework.ExecuteScriptName, harness.Framework.ExecuteScript);
            File.WriteAllText(page.RootPath + harness.Framework.ReportScriptName, harness.Framework.ReportScript);

            foreach (var scriptFile in harnessView.SystemScripts)
                CopyScript(page.RootPath, scriptFile);
			
			
			
            foreach (var scriptFile in harnessView.CaseScripts)
                CopyScript(page.RootPath, scriptFile);

            File.WriteAllText(page.Filename, result);

            return page;
        }
コード例 #2
0
ファイル: PageGenerator.cs プロジェクト: dolittle/Forseti
        public Page GenerateFrom(Harness harness)
        {
            var page = new Page();

            var harnessView = (HarnessView)_engine.CreateInstance(_descriptor);
            harnessView.Harness = harness;
            harnessView.RunnerScripts = new[] {"jquery.min.js","forseti.bootstrapper.js", "r.js", "forseti.js"} ;
            harnessView.FrameworkScript = harness.Framework.ScriptName;
            harnessView.FrameworkExecutionScript = harness.Framework.ExecuteScriptName;
            harnessView.FrameworkReportingScript = harness.Framework.ReportScriptName;

            page.RootPath = Path.GetTempPath() + @"Forseti/";
            page.Filename = string.Format("{0}runner.html", page.RootPath);

            if (!Directory.Exists(page.RootPath))
                Directory.CreateDirectory(page.RootPath);

            if (harness.HasDependencies())
            {
                var actualDependencies = new List<string>();
                foreach (var dependency in harness.Dependencies)
                {
                    CopyScript(page, dependency.RelativePath);
                    actualDependencies.Add(dependency.RelativePath);
                }
                harnessView.Dependencies = actualDependencies.ToArray();
            } else {
				harnessView.Dependencies = new string[0];
			}
							

            var writer = new StringWriter();

            foreach (var scriptFile in harnessView.SystemScripts)
                CopyScriptAndPossibleAdditionalReferences(harness, page, scriptFile);

            var actualCaseScripts = new List<CaseScriptDescriptor>();
            foreach (var caseDescriptor in harnessView.CaseScripts)
            {
                var additionalRefereces = CopyScriptAndPossibleAdditionalReferences(harness, page, caseDescriptor.Case);
                actualCaseScripts.Add(new CaseScriptDescriptor { CaseDependencies = additionalRefereces, Case = caseDescriptor.Case });
            }
            harnessView.CaseScripts = actualCaseScripts.ToArray();


            harnessView.RenderView(writer);

            var result = writer.ToString();

            File.WriteAllText(page.RootPath + "jquery.min.js", _jqueryJs);
            File.WriteAllText(page.RootPath + "forseti.bootstrapper.js", _forsetiBootstrapperJs);
            File.WriteAllText(page.RootPath + "r.js", _requireJs);
            File.WriteAllText(page.RootPath + "forseti.js", _forsetiJs);
            File.WriteAllText(page.RootPath + harness.Framework.ScriptName, harness.Framework.Script);
            File.WriteAllText(page.RootPath + harness.Framework.ExecuteScriptName, harness.Framework.ExecuteScript);
            File.WriteAllText(page.RootPath + harness.Framework.ReportScriptName, harness.Framework.ReportScript);

			
            
            File.WriteAllText(page.Filename, result);

            return page;
        }