public void PostProcessGeneratedCodeAddsStaticApplicationInstanceProperty() { // Arrange WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); CodeGeneratorContext context = CodeGeneratorContext.Create( host, () => new CSharpCodeWriter(), "TestClass", "TestNamespace", "Foo.cshtml", shouldGenerateLinePragmas: true); // Act host.PostProcessGeneratedCode(context); // Assert CodeMemberProperty appInstance = context.GeneratedClass .Members .OfType <CodeMemberProperty>() .Where(p => p.Name.Equals("ApplicationInstance")) .SingleOrDefault(); Assert.NotNull(appInstance); Assert.True(appInstance.Attributes.HasFlag(MemberAttributes.Static)); }
public void PostProcessGeneratedCodeRemovesExecuteMethod() { // Arrange CodeCompileUnit ccu = new CodeCompileUnit(); CodeNamespace ns = new CodeNamespace(); CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(); CodeMemberMethod executeMethod = new CodeMemberMethod(); typeDecl.Members.Add(executeMethod); WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); // Act host.PostProcessGeneratedCode(ccu, ns, typeDecl, executeMethod); // Assert Assert.AreEqual(0, typeDecl.Members.OfType<CodeMemberMethod>().Count()); }
public void PostProcessGeneratedCodeRemovesExecuteMethod() { // Arrange CodeCompileUnit ccu = new CodeCompileUnit(); CodeNamespace ns = new CodeNamespace(); CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(); CodeMemberMethod executeMethod = new CodeMemberMethod(); typeDecl.Members.Add(executeMethod); WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); // Act host.PostProcessGeneratedCode(ccu, ns, typeDecl, executeMethod); // Assert Assert.AreEqual(0, typeDecl.Members.OfType <CodeMemberMethod>().Count()); }
public void PostProcessGeneratedCodeRemovesExecuteMethod() { // Arrange WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); CodeGeneratorContext context = CodeGeneratorContext.Create( host, () => new CSharpCodeWriter(), "TestClass", "TestNamespace", "TestFile.cshtml", shouldGenerateLinePragmas: true); // Act host.PostProcessGeneratedCode(context); // Assert Assert.Equal(0, context.GeneratedClass.Members.OfType<CodeMemberMethod>().Count()); }
public void PostProcessGeneratedCodeRemovesExecuteMethod() { // Arrange WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); CodeGeneratorContext context = CodeGeneratorContext.Create( host, () => new CSharpCodeWriter(), "TestClass", "TestNamespace", "TestFile.cshtml", shouldGenerateLinePragmas: true); // Act host.PostProcessGeneratedCode(context); // Assert Assert.Equal(0, context.GeneratedClass.Members.OfType <CodeMemberMethod>().Count()); }
public void PostProcessGeneratedCodeAddsStaticApplicationInstanceProperty() { // Arrange CodeCompileUnit ccu = new CodeCompileUnit(); CodeNamespace ns = new CodeNamespace(); CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(); CodeMemberMethod executeMethod = new CodeMemberMethod(); typeDecl.Members.Add(executeMethod); WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); // Act host.PostProcessGeneratedCode(ccu, ns, typeDecl, executeMethod); // Assert CodeMemberProperty appInstance = typeDecl.Members .OfType <CodeMemberProperty>() .Where(p => p.Name.Equals("ApplicationInstance")) .SingleOrDefault(); Assert.IsNotNull(appInstance); Assert.IsTrue(appInstance.Attributes.HasFlag(MemberAttributes.Static)); }
public void PostProcessGeneratedCodeAddsStaticApplicationInstanceProperty() { // Arrange WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); CodeGeneratorContext context = CodeGeneratorContext.Create( host, () => new CSharpCodeWriter(), "TestClass", "TestNamespace", "Foo.cshtml", shouldGenerateLinePragmas: true); // Act host.PostProcessGeneratedCode(context); // Assert CodeMemberProperty appInstance = context.GeneratedClass .Members .OfType<CodeMemberProperty>() .Where(p => p.Name.Equals("ApplicationInstance")) .SingleOrDefault(); Assert.NotNull(appInstance); Assert.True(appInstance.Attributes.HasFlag(MemberAttributes.Static)); }
public void PostProcessGeneratedCodeAddsStaticApplicationInstanceProperty() { // Arrange CodeCompileUnit ccu = new CodeCompileUnit(); CodeNamespace ns = new CodeNamespace(); CodeTypeDeclaration typeDecl = new CodeTypeDeclaration(); CodeMemberMethod executeMethod = new CodeMemberMethod(); typeDecl.Members.Add(executeMethod); WebCodeRazorHost host = new WebCodeRazorHost("Foo.cshtml"); // Act host.PostProcessGeneratedCode(ccu, ns, typeDecl, executeMethod); // Assert CodeMemberProperty appInstance = typeDecl.Members .OfType<CodeMemberProperty>() .Where(p => p.Name.Equals("ApplicationInstance")) .SingleOrDefault(); Assert.IsNotNull(appInstance); Assert.IsTrue(appInstance.Attributes.HasFlag(MemberAttributes.Static)); }