public void ParserThrowsOnInfiniteNestedCalls() { var data = new Dictionary <string, object>(); var template = @"{{#declare TestPartial}}{{#IMPORT 'TestPartial'}}{{/declare}}{{#IMPORT 'TestPartial'}}"; var parsingOptions = new ParserOptions(template, null, ParserFixture.DefaultEncoding); var parsedTemplate = Parser.ParseWithOptions(parsingOptions); ParserFixture.TestLocationsInOrder(parsedTemplate); Assert.That(async() => await parsedTemplate.CreateAndStringifyAsync(data), Throws.Exception.TypeOf <MustachioStackOverflowException>()); SerilalizerTests.SerializerTest.AssertDocumentItemIsSameAsTemplate(parsingOptions.Template, parsedTemplate.Document, parsingOptions); }
public void TestGetCurrent() { var morestachioDocumentInfo = GenerateTemplate("{{test}}content{{#if test}}data{{/if}}"); var api = morestachioDocumentInfo.Fluent(); api.Current(f => Assert.That(f, Is.TypeOf <MorestachioDocument>())) .FindNext <PathDocumentItem>() .IfNotSuccess(f => Assert.Fail("Could not find PathDocumentItem")) .Current(f => Assert.That(f, Is.TypeOf <PathDocumentItem>())) .FindNext <ContentDocumentItem>() .IfNotSuccess(f => Assert.Fail("Could not find ContentDocumentItem")) .Current(f => Assert.That(f, Is.TypeOf <ContentDocumentItem>())) .FindNext <IfExpressionScopeDocumentItem>() .IfNotSuccess(f => Assert.Fail("Could not find IfExpressionScopeDocumentItem")) .Current(f => Assert.That(f, Is.TypeOf <IfExpressionScopeDocumentItem>())) .FindNext <PathDocumentItem>() .IfSuccess(f => Assert.Fail("Found PathDocumentItem but should have not")) .Current(f => Assert.That(f, Is.TypeOf <IfExpressionScopeDocumentItem>())); ParserFixture.TestLocationsInOrder(morestachioDocumentInfo); }