Exemplo n.º 1
0
        public void CreateParserMethodPassesParsersThroughDecoratorMethodsOnHost()
        {
            // Arrange
            ParserBase expectedCode   = new Mock <ParserBase>().Object;
            ParserBase expectedMarkup = new Mock <ParserBase>().Object;

            var mockHost = new Mock <RazorEngineHost>(new CSharpRazorCodeLanguage())
            {
                CallBase = true
            };

            mockHost
            .Setup(h => h.DecorateCodeParser(It.IsAny <CSharpCodeParser>()))
            .Returns(expectedCode);
            mockHost
            .Setup(h => h.DecorateMarkupParser(It.IsAny <HtmlMarkupParser>()))
            .Returns(expectedMarkup);
            RazorTemplateEngine engine = new RazorTemplateEngine(mockHost.Object);

            // Act
            RazorParser actual = engine.CreateParser();

            // Assert
            Assert.Equal(expectedCode, actual.CodeParser);
            Assert.Equal(expectedMarkup, actual.MarkupParser);
        }
        public void CreateParserMethodSetsParserContextToDesignTimeModeIfHostSetToDesignTimeMode() {
            // Arrange
            RazorEngineHost host = CreateHost();
            RazorTemplateEngine engine = new RazorTemplateEngine(host);
            host.DesignTimeMode = true;

            // Act
            RazorParser parser = engine.CreateParser();

            // Assert
            Assert.IsTrue(parser.DesignTimeMode);
        }
        public void CreateParserMethodIsConstructedFromHost() {
            // Arrange
            RazorEngineHost host = CreateHost();
            RazorTemplateEngine engine = new RazorTemplateEngine(host);

            // Act
            RazorParser parser = engine.CreateParser();
            
            // Assert
            Assert.IsInstanceOfType(parser.CodeParser, typeof(CSharpCodeParser));
            Assert.IsInstanceOfType(parser.MarkupParser, typeof(HtmlMarkupParser));
        }
        public void CreateParserMethodIsConstructedFromHost()
        {
            // Arrange
            var host   = CreateHost();
            var engine = new RazorTemplateEngine(host);

            // Act
            var parser = engine.CreateParser("some-file");

            // Assert
            Assert.IsType <CSharpCodeParser>(parser.CodeParser);
            Assert.IsType <HtmlMarkupParser>(parser.MarkupParser);
        }
        public void CreateParserMethodIsConstructedFromHost()
        {
            // Arrange
            RazorEngineHost     host   = CreateHost();
            RazorTemplateEngine engine = new RazorTemplateEngine(host);

            // Act
            RazorParser parser = engine.CreateParser();

            // Assert
            Assert.IsType <CSharpCodeParser>(parser.CodeParser);
            Assert.IsType <HtmlMarkupParser>(parser.MarkupParser);
        }
Exemplo n.º 6
0
        public void CreateParserMethodSetsParserContextToDesignTimeModeIfHostSetToDesignTimeMode()
        {
            // Arrange
            var host = CreateHost();
            var engine = new RazorTemplateEngine(host);
            host.DesignTimeMode = true;

            // Act
            var parser = engine.CreateParser("some-file");

            // Assert
            Assert.True(parser.DesignTimeMode);
        }
Exemplo n.º 7
0
        public void CreateParserMethodIsConstructedFromHost()
        {
            // Arrange
            var host = CreateHost();
            var engine = new RazorTemplateEngine(host);

            // Act
            var parser = engine.CreateParser("some-file");

            // Assert
            Assert.IsType<CSharpCodeParser>(parser.CodeParser);
            Assert.IsType<HtmlMarkupParser>(parser.MarkupParser);
        }
        public void CreateParserMethodSetsParserContextToDesignTimeModeIfHostSetToDesignTimeMode()
        {
            // Arrange
            var host   = CreateHost();
            var engine = new RazorTemplateEngine(host);

            host.DesignTimeMode = true;

            // Act
            var parser = engine.CreateParser("some-file");

            // Assert
            Assert.True(parser.DesignTimeMode);
        }
        public void CreateParserMethodSetsParserContextToDesignTimeModeIfHostSetToDesignTimeMode()
        {
            // Arrange
            RazorEngineHost     host   = CreateHost();
            RazorTemplateEngine engine = new RazorTemplateEngine(host);

            host.DesignTimeMode = true;

            // Act
            RazorParser parser = engine.CreateParser();

            // Assert
            Assert.True(parser.DesignTimeMode);
        }
        public void CreateParserMethodPassesParsersThroughDecoratorMethodsOnHost() {
            // Arrange
            CodeParser expectedCode = new Mock<CodeParser>().Object;
            MarkupParser expectedMarkup = new Mock<MarkupParser>().Object;

            var mockHost = new Mock<RazorEngineHost>(new CSharpRazorCodeLanguage()) { CallBase = true };
            mockHost.Setup(h => h.DecorateCodeParser(It.IsAny<CSharpCodeParser>()))
                    .Returns(expectedCode);
            mockHost.Setup(h => h.DecorateMarkupParser(It.IsAny<HtmlMarkupParser>()))
                    .Returns(expectedMarkup);
            RazorTemplateEngine engine = new RazorTemplateEngine(mockHost.Object);

            // Act
            RazorParser actual = engine.CreateParser();

            // Assert
            Assert.AreEqual(expectedCode, actual.CodeParser);
            Assert.AreEqual(expectedMarkup, actual.MarkupParser);
        }