public void CodeDomProviderTypeReturnsVBCodeProvider() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Assert Assert.AreEqual(typeof(VBCodeProvider), service.CodeDomProviderType); }
private Type GenerateTemplateTypes <T>(string templateName) { var source = ContentReader.ReadTemplate(templateName); var className = templateName.Replace(".", "_"); // determine language, pass into generateAssembly RazorCodeLanguage codeLanguage; switch (templateName.Substring(templateName.LastIndexOf("."))) { case ".cshtml": codeLanguage = new CSharpRazorCodeLanguage(); break; case ".vbhtml": codeLanguage = new VBRazorCodeLanguage(); break; default: throw new ApplicationException("Unsupported Template language. Either .cshtml or .vbhtml"); } var razorEngine = CreateRazorEngine <T>(codeLanguage); var assembly = GenerateAssembly <T>(razorEngine, className, source); return(assembly.GetType(NamespaceName + "." + className, true, false)); }
public void CodeDomProviderTypeReturnsVBCodeProvider() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Assert Assert.Equal(typeof(VBCodeProvider), service.CodeDomProviderType); }
public void CreateCodeParserReturnsNewVBCodeParser() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Act ParserBase parser = service.CreateCodeParser(); // Assert Assert.IsNotNull(parser); Assert.IsInstanceOfType(parser, typeof(VBCodeParser)); }
public void CreateCodeParserReturnsNewVBCodeParser() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Act ParserBase parser = service.CreateCodeParser(); // Assert Assert.NotNull(parser); Assert.IsType<VBCodeParser>(parser); }
public void CreateCodeParserReturnsNewVBCodeParser() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Act ParserBase parser = service.CreateCodeParser(); // Assert Assert.NotNull(parser); Assert.IsType <VBCodeParser>(parser); }
public void CreateCodeParserReturnsNewVBCodeParser() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Act ParserBase parser = service.CreateCodeParser(); // Assert Assert.IsNotNull(parser); Assert.IsInstanceOfType(parser, typeof(VBCodeParser)); }
public void CreateCodeGeneratorParserListenerReturnsNewCSharpCodeGeneratorParserListener() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Act RazorEngineHost host = new RazorEngineHost(new VBRazorCodeLanguage()); RazorCodeGenerator generator = service.CreateCodeGenerator("Foo", "Bar", "Baz", host); // Assert Assert.IsNotNull(generator); Assert.IsInstanceOfType(generator, typeof(VBRazorCodeGenerator)); Assert.AreEqual("Foo", generator.ClassName); Assert.AreEqual("Bar", generator.RootNamespaceName); Assert.AreEqual("Baz", generator.SourceFileName); Assert.AreSame(host, generator.Host); }
public void CreateCodeGeneratorParserListenerReturnsNewCSharpCodeGeneratorParserListener() { // Arrange RazorCodeLanguage service = new VBRazorCodeLanguage(); // Act RazorEngineHost host = new RazorEngineHost(new VBRazorCodeLanguage()); RazorCodeGenerator generator = service.CreateCodeGenerator("Foo", "Bar", "Baz", host); // Assert Assert.NotNull(generator); Assert.IsType <VBRazorCodeGenerator>(generator); Assert.Equal("Foo", generator.ClassName); Assert.Equal("Bar", generator.RootNamespaceName); Assert.Equal("Baz", generator.SourceFileName); Assert.Same(host, generator.Host); }
public static RazorCodeLanguage Create(string extension) { RazorCodeLanguage language; switch (extension) { case ".cshtml": language = new FubuCSharpRazorCodeLanguage(); break; case ".vbhtml": language = new VBRazorCodeLanguage(); break; default: throw new ArgumentException("Invalid extension for Razor engine."); } return(language); }