コード例 #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 AddValueBuilderErrosTests()
        {
            //todo: test this actually got added
            var fetcherMock = new Mock<IFileFetcher>();
            var functionValueBuilderMock = new Mock<IFunctionValueBuilder<IFunctionValue>>();

            var viewBuilder = new ViewBuilder(fetcherMock.Object);

            Assert.Throws<ArgumentNullException>(() => viewBuilder.AddValueBuilder(null, null));
            Assert.Throws<ArgumentNullException>(() => viewBuilder.AddValueBuilder("", null));
            Assert.Throws<ArgumentNullException>(() => viewBuilder.AddValueBuilder("", functionValueBuilderMock.Object));
            Assert.Throws<ArgumentNullException>(() => viewBuilder.AddValueBuilder("hi", null));

            Assert.DoesNotThrow(() => viewBuilder.AddValueBuilder("yo", functionValueBuilderMock.Object));
        }
コード例 #3
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);
        }
コード例 #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 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);
        }
コード例 #6
0
        public void ConstructorTests()
        {
            Assert.Throws<ArgumentNullException>(() => new ViewBuilder(null));

            var fetcherMock = new Mock<IFileFetcher>();

            var viewBuilder = new ViewBuilder(fetcherMock.Object);

            Assert.IsNotNull(viewBuilder);
        }
コード例 #7
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));
        }