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 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)); }
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 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 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 ConstructorTests() { Assert.Throws<ArgumentNullException>(() => new ViewBuilder(null)); var fetcherMock = new Mock<IFileFetcher>(); var viewBuilder = new ViewBuilder(fetcherMock.Object); Assert.IsNotNull(viewBuilder); }
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)); }