public void GenerateCode_ThrowsIfItemCannotBeFound() { // Arrange var project = new TestRazorProject(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act & Assert var ex = Assert.Throws <InvalidOperationException>( () => templateEngine.GenerateCode("/does-not-exist.cstml")); Assert.Equal("The item '/does-not-exist.cstml' could not be found.", ex.Message); }
public void GenerateCode_ThrowsIfProjectItemCannotBeFound() { // Arrange var path = "/Views/Home/Index.cshtml"; var project = new TestRazorProject(new RazorProjectItem[] { }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act & Assert var ex = Assert.Throws <InvalidOperationException>(() => templateEngine.GenerateCode(path)); Assert.Equal($"The item '{path}' could not be found.", ex.Message); }
public void GenerateCode_WithPath() { // Arrange var path = "/Views/Home/Index.cshtml"; var projectItem = new TestRazorProjectItem(path); var project = new TestRazorProject(new[] { projectItem }); var razorEngine = RazorEngine.Create(); var templateEngine = new RazorTemplateEngine(razorEngine, project); // Act var cSharpDocument = templateEngine.GenerateCode(path); // Assert Assert.NotNull(cSharpDocument); Assert.NotEmpty(cSharpDocument.GeneratedCode); Assert.Empty(cSharpDocument.Diagnostics); }