public ITag Parse(bool expectTag = false) { if (!_helper.At(TagLibConstants.START_TAG)) { _helper.Read(TagLibConstants.START_TAG); } if (_helper.IsAhead(TagLibConstants.CLOSE_SLASH)) { return(ParseCloseTag()); } var context = _helper.Current.Context; if (expectTag && !_helper.IsAhead(TokenType.Regular)) { throw TagException.ExpectedTagOrGroupName(_helper.Lookahead.Contents).Decorate(_helper.Lookahead.Context); } var tag = ParseOpenTag(); if (tag != null) { tag.Context = context; } ValidateTag(tag); return(tag); }
public void Should_Throw_Correct_Error_Message_On_Invalid_Char_After_Opening() { const string TEMPLATE = "<choose>< otherwise></otherwise></choose>"; var model = new TestModel(); try { var formatter = new Formatter(TEMPLATE).SwitchToMode(TagLibMode.StrictResolve).Parse(); Assert.Fail("Expected exception"); } catch (TagException Te) { Assert.That(Te.MessageWithOutContext, Text.StartsWith(TagException.ExpectedTagOrGroupName(" ").Message)); } }