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); }
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); }
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); }
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); }
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)); }