コード例 #1
0
        public void AtRules()
        {
            var fileFetcherMock = new Mock<IFileFetcher>();

            fileFetcherMock.Setup(ff => ff.GetText(It.IsAny<string>()))
                .Returns(@"<html><head><script type=""text/yate"">@if true(){body{text:hi}}</script></head><body></body></html>");

            var builder = new ViewBuilder(fileFetcherMock.Object);

            var htmls = builder.Build("asdf").Render(new Mock<IYateDataContext>().Object);
        }
コード例 #2
0
        public void BasicBuildTest()
        {
            var fileFetcherMock = new Mock<IFileFetcher>();

            fileFetcherMock.Setup(ff => ff.GetText(It.IsAny<string>())).Returns(Helpers.EmptyHtmlString);

            var builder = new ViewBuilder(fileFetcherMock.Object);

            var view = builder.Build("yeah buddy");

            Assert.IsNotNull(view);
        }
コード例 #3
0
        public void DoesItUseFunctionValues()
        {
            var fileFetcherMock = new Mock<IFileFetcher>();

            fileFetcherMock.Setup(ff => ff.GetText(It.IsAny<string>()))
                .Returns(@"<html><head><script type=""text/yate"">body{text:if(false(),nope,yup);}</script></head><body></body></html>");

            var builder = new ViewBuilder(fileFetcherMock.Object);

            var htmls = builder.Build("asdf").Render(new Mock<IYateDataContext>().Object);

            Assert.AreEqual(@"<html><head></head><body>yup</body></html>", htmls);
        }
コード例 #4
0
        public void GrabYateScriptFromTemplate()
        {
            var fileFetcherMock = new Mock<IFileFetcher>();

            fileFetcherMock.Setup(ff => ff.GetText(It.IsAny<string>()))
                .Returns(@"<html><head><script type=""text/yate"">body{text:hi;}</script></head><body></body></html>");

            var builder = new ViewBuilder(fileFetcherMock.Object);

            var htmls = builder.Build("asdf").Render(new Mock<IYateDataContext>().Object);

            fileFetcherMock.Verify(ff => ff.GetText(It.IsAny<string>()), Times.Once());

            Assert.AreEqual(@"<html><head></head><body>hi</body></html>", htmls);
        }
コード例 #5
0
        public void BuildNoFilePathGiven()
        {
            var fileFetcherMock = new Mock<IFileFetcher>();
            var builder = new ViewBuilder(fileFetcherMock.Object);

            Assert.Throws<ArgumentNullException>(() => builder.Build(""));
            Assert.Throws<ArgumentNullException>(() => builder.Build(null));
        }