Exemple #1
0
        public string GenerateTest(SyntaxTree tree, string name)
        {
            this.IndentingWriter = IndentingTextWriter.Get(new StringWriter());
            this.sb = new StringBuilder();

            this.sb.AppendLine();
            this.sb.AppendLine("using LanguageModel.Tests.TestGeneration;");
            this.sb.AppendLine("using LanguageService;");
            this.sb.AppendLine("using Xunit;");
            this.sb.AppendLine("namespace LanguageModel.Tests.GeneratedTestFiles");
            this.sb.AppendLine("{");
            this.sb.AppendLine(string.Format("    class {0}", name));
            this.sb.AppendLine("    {");
            this.sb.AppendLine("        [Fact]");
            this.sb.AppendLine("        public void Test(Tester t)");
            this.sb.AppendLine("        {");

            using (this.IndentingWriter.Indent())
            {
                using (this.IndentingWriter.Indent())
                {
                    using (this.IndentingWriter.Indent())
                    {
                        this.GenerateTestStructure(tree.Root);
                    }
                }
            }

            this.sb.Append(this.IndentingWriter.ToString());
            this.sb.AppendLine("        }");
            this.sb.AppendLine("    }");
            this.sb.AppendLine("}");
            return(this.sb.ToString());
        }