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 ConstructorWithVirtualAndPhysicalPathSetsDefaultProperties() { // Act WebCodeRazorHost host = new WebCodeRazorHost("~/Foo/App_Code/Bar/Baz/Qux.cshtml", @"C:\Qux.doodad"); // Assert Assert.AreEqual("System.Web.WebPages.HelperPage", host.DefaultBaseClass); Assert.AreEqual("ASP.Bar.Baz", host.DefaultNamespace); Assert.AreEqual("Qux", host.DefaultClassName); Assert.IsFalse(host.DefaultDebugCompilation); }
public void ConstructorWithFileOnlyVirtualPathSetsDefaultProperties() { // Act WebCodeRazorHost host = new WebCodeRazorHost(@"Foo.cshtml"); // Assert Assert.AreEqual("System.Web.WebPages.HelperPage", host.DefaultBaseClass); Assert.AreEqual("ASP", host.DefaultNamespace); Assert.AreEqual("Foo", host.DefaultClassName); Assert.IsFalse(host.DefaultDebugCompilation); }
/// <summary> /// Starts the application /// </summary> public static void Start() { Crud.RouteConfig.RegisterRoutes(RouteTable.Routes); Crud.BundleConfig.RegisterBundles(BundleTable.Bundles); System.Web.Mvc.ControllerBuilder.Current.DefaultNamespaces.Add("Psns.Common.Mvc.Crudified.Controllers"); WebCodeRazorHost.AddGlobalImport("System.Web.Optimization"); WebCodeRazorHost.AddGlobalImport("Psns.Common.Mvc.ViewBuilding.Menu"); GlobalMenu.ContextMenu = new Infrastructure.ContextMenu(); }
public void ConstructorWithFileOnlyVirtualPathSetsDefaultProperties() { // Act WebCodeRazorHost host = new WebCodeRazorHost(@"Foo.cshtml"); // Assert Assert.Equal("System.Web.WebPages.HelperPage", host.DefaultBaseClass); Assert.Equal("ASP", host.DefaultNamespace); Assert.Equal("Foo", host.DefaultClassName); Assert.False(host.DefaultDebugCompilation); }
public void ConstructorWithVirtualAndPhysicalPathSetsDefaultProperties() { // Act WebCodeRazorHost host = new WebCodeRazorHost("~/Foo/App_Code/Bar/Baz/Qux.cshtml", @"C:\Qux.doodad"); // Assert Assert.Equal("System.Web.WebPages.HelperPage", host.DefaultBaseClass); Assert.Equal("ASP.Bar.Baz", host.DefaultNamespace); Assert.Equal("Qux", host.DefaultClassName); Assert.False(host.DefaultDebugCompilation); }
public void ConstructorWithMalformedVirtualPathSetsDefaultProperties() { // Act WebCodeRazorHost host = new WebCodeRazorHost(@"~/Foo/App_Code\Bar\Baz\Qux.cshtml"); // Assert Assert.AreEqual("System.Web.WebPages.HelperPage", host.DefaultBaseClass); Assert.AreEqual("ASP.Bar.Baz", host.DefaultNamespace); Assert.AreEqual("Qux", host.DefaultClassName); Assert.IsFalse(host.DefaultDebugCompilation); Assert.IsTrue(host.StaticHelpers); }
public void ConstructorWithMalformedVirtualPathSetsDefaultProperties() { // Act WebCodeRazorHost host = new WebCodeRazorHost(@"~/Foo/App_Code\Bar\Baz\Qux.cshtml"); // Assert Assert.Equal("System.Web.WebPages.HelperPage", host.DefaultBaseClass); Assert.Equal("ASP.Bar.Baz", host.DefaultNamespace); Assert.Equal("Qux", host.DefaultClassName); Assert.False(host.DefaultDebugCompilation); Assert.True(host.StaticHelpers); }
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()); }
/// <summary> /// Starts the application /// </summary> public static void Start() { Crud.RouteConfig.RegisterRoutes(RouteTable.Routes); Crud.BundleConfig.RegisterBundles(BundleTable.Bundles); Crud.WebApiConfig.Register(GlobalConfiguration.Configuration); System.Web.Mvc.ControllerBuilder.Current.DefaultNamespaces.Add("Psns.Common.Mvc.Crudified.Controllers"); WebCodeRazorHost.AddGlobalImport("System.Web.Optimization"); WebCodeRazorHost.AddGlobalImport("Psns.Common.Mvc.ViewBuilding.Menu"); GlobalConfiguration.Configuration .Formatters .JsonFormatter .SerializerSettings .ContractResolver = new CamelCasePropertyNamesContractResolver(); GlobalMenu.ContextMenu = new Infrastructure.ContextMenu(); }
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 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 static void InitializeApplication() { WebCodeRazorHost.AddGlobalImport("MvcMate.Web.Mvc.Html"); }
public static void InitializeApplication() { WebCodeRazorHost.AddGlobalImport("Website.ContentFileHelper"); }
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)); }
/// <summary> /// Starts the application /// </summary> public static void Start() { PsnsThemeBundleConfig.RegisterBundles(BundleTable.Bundles); WebCodeRazorHost.AddGlobalImport("System.Web.Optimization"); WebCodeRazorHost.AddGlobalImport("Psns.Common.Mvc.Skin.Menu"); }