public StringTemplate LoadTemplate(string name) { if (_templateGroup == null) { _templateGroup = new StringTemplateGroup("MG", GLexConfig.TemplatePath, typeof(DefaultTemplateLexer)); _templateGroup.RegisterAttributeRenderer(typeof(bool), TemplateRenderers.BoolRenderer.Instance); _templateGroup.RegisterAttributeRenderer(typeof(Color), TemplateRenderers.ColorRenderer.Instance); _templateGroup.RegisterAttributeRenderer(typeof(DateTime), TemplateRenderers.DateTimeRenderer.Instance); _templateGroup.RegisterAttributeRenderer(typeof(Vector3), TemplateRenderers.VectorRenderer.Instance); _templateGroup.RegisterAttributeRenderer(typeof(Vector2), TemplateRenderers.VectorRenderer.Instance); _templateGroup.RegisterAttributeRenderer(typeof(Matrix4x4), TemplateRenderers.MatrixRenderer.Instance); } Debug.Log (name); return _templateGroup.GetInstanceOf(GLexConfig.GetTemplate(name)); }
/** * Instantiates an instance of the CxxTestDriverGenerator for the * specified project and test suite collection. * * @param project the ICProject associated with this generator * @param path the path of the source file to be generated * @param suites the collection of test suites to be generated * * @throws IOException if an I/O error occurs during generation */ public TestRunnerGenerator(string path, TestSuiteCollection suites, Dictionary<string, bool> testsToRun) { this.suites = suites; this.runnerPath = path; // Create a proxy object to manage the tests to run. Any tests // not in this map are assumed to be true (so that if tests // have been added, but not refreshed in the tool window, they // will be run until they are explicitly disabled). this.testsToRunProxy = new TestsToRunProxy(testsToRun); // Load the template from the embedded assembly resources. Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( RunnerTemplateResourcePath); StringTemplateGroup templateGroup = new StringTemplateGroup( new StreamReader(stream), typeof(AngleBracketTemplateLexer)); templateGroup.RegisterAttributeRenderer(typeof(string), new TestRunnerStringRenderer(path)); template = templateGroup.GetInstanceOf("runAllTestsFile"); // Initialize the options that will be passed into the template. options = new Hashtable(); options["platformIsMSVC"] = true; options["trapSignals"] = true; options["traceStack"] = true; options["noStaticInit"] = true; options["root"] = true; options["part"] = false; options["abortOnFail"] = true; options["longLongType"] = null; options["mainProvided"] = suites.MainFunctionExists; options["runner"] = "XmlStdioPrinter"; options["xmlOutput"] = true; options["testResultsFilename"] = Constants.TestResultsFilename; options["testsToRun"] = testsToRunProxy; writer = File.CreateText(path); }
private void WriteHeaderFileContent(TextWriter writer, string suitePath) { Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( NewTestSuiteTemplateResourcePath); StringTemplateGroup templateGroup = new StringTemplateGroup( new StreamReader(stream), typeof(AngleBracketTemplateLexer)); templateGroup.RegisterAttributeRenderer(typeof(string), new NewTestSuiteStringRenderer(suitePath)); StringTemplate template = templateGroup.GetInstanceOf("newSuiteFile"); // Initialize the options that will be passed into the template. Hashtable options = new Hashtable(); options["suiteName"] = suiteName; options["superclass"] = superclass; options["headerUnderTest"] = headerUnderTest.CanonicalName; options["createSetUp"] = createSetUp; options["createTearDown"] = createTearDown; template.SetAttribute("options", options); template.SetAttribute("testCases", new List<string>(stubNames)); template.Write(new AutoIndentWriter(writer)); }