public void CreateCodeGenerator_PassesChunkGeneratorThroughDecorateMethodOnHost() { // Arrange var mockHost = new Mock <RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true }; var codeGeneratorContext = new CodeGeneratorContext( mockHost.Object, "different-class", "different-ns", string.Empty, shouldGenerateLinePragmas: true, errorSink: new ErrorSink()); var expected = new CSharpCodeGenerator(codeGeneratorContext); mockHost .Setup(h => h.DecorateCodeGenerator(It.IsAny <CSharpCodeGenerator>(), codeGeneratorContext)) .Returns(expected); var engine = new RazorTemplateEngine(mockHost.Object); // Act var actual = engine.CreateCodeGenerator(codeGeneratorContext); // Assert Assert.Equal(expected, actual); }
public void CreateCodeGeneratorMethodPassesCodeGeneratorThroughDecorateMethodOnHost() { // Arrange var mockHost = new Mock <RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true }; RazorCodeGenerator expected = new Mock <RazorCodeGenerator>("Foo", "Bar", "Baz", mockHost.Object).Object; mockHost.Setup(h => h.DecorateCodeGenerator(It.IsAny <CSharpRazorCodeGenerator>())) .Returns(expected); RazorTemplateEngine engine = new RazorTemplateEngine(mockHost.Object); // Act RazorCodeGenerator actual = engine.CreateCodeGenerator("Foo", "Bar", "Baz"); // Assert Assert.Equal(expected, actual); }
public void CreateCodeGeneratorMethodPassesCodeGeneratorThroughDecorateMethodOnHost() { // Arrange var mockHost = new Mock<RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true }; RazorCodeGenerator expected = new Mock<RazorCodeGenerator>("Foo", "Bar", "Baz", mockHost.Object).Object; mockHost.Setup(h => h.DecorateCodeGenerator(It.IsAny<CSharpRazorCodeGenerator>())) .Returns(expected); RazorTemplateEngine engine = new RazorTemplateEngine(mockHost.Object); // Act RazorCodeGenerator actual = engine.CreateCodeGenerator("Foo", "Bar", "Baz"); // Assert Assert.AreEqual(expected, actual); }
public void CreateCodeGenerator_PassesChunkGeneratorThroughDecorateMethodOnHost() { // Arrange var mockHost = new Mock<RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true }; var codeGeneratorContext = new CodeGeneratorContext( mockHost.Object, "different-class", "different-ns", string.Empty, shouldGenerateLinePragmas: true, errorSink: new ErrorSink()); var expected = new CSharpCodeGenerator(codeGeneratorContext); mockHost.Setup(h => h.DecorateCodeGenerator(It.IsAny<CSharpCodeGenerator>(), codeGeneratorContext)) .Returns(expected); var engine = new RazorTemplateEngine(mockHost.Object); // Act var actual = engine.CreateCodeGenerator(codeGeneratorContext); // Assert Assert.Equal(expected, actual); }