public void InsertTemplateWithIllegalAttribute() { var tag = new InsertTemplate() { Template = new MockAttribute(new Constant("insertEMaster.htm")) }; tag.Factory = _factory; var setAttribute = new Set { Var = new MockAttribute(new Constant("body")), Body = new MockAttribute(new Constant("Dit is de Test Body")) }; try { tag.AddNestedTag(setAttribute); string expected = (new StreamReader("insertEExpected.htm")).ReadToEnd(); tag.Evaluate(_model); Assert.Fail("Expect exception"); } catch (TagException Te) { Assert.That(Te.Message, Is.EqualTo( TagException.OnlyNestedTagsOfTypeAllowed(setAttribute.GetType(), typeof(PutAttribute)). Message)); } }
public void AddNestedTag(ITag tag) { if (tag is Param) { _nestedTags.Add((Param)tag); } else { throw TagException.OnlyNestedTagsOfTypeAllowed(tag.GetType(), typeof(Param)).Decorate(tag.Context); } }
public void AddNestedTag(ITag tag) { if (tag is When || tag is Otherwise) { _nestedTags.Add(tag); } else { throw TagException.OnlyNestedTagsOfTypeAllowed(tag.GetType(), typeof(When), typeof(Otherwise)). Decorate(tag.Context); } }
public void BadTag() { var tag = new Choose(); var outTag = new Out(); try { tag.AddNestedTag(outTag); } catch (TagException Te) { Assert.AreEqual(Te.Message, TagException.OnlyNestedTagsOfTypeAllowed(typeof(Out), typeof(When), typeof(When))); } }
public void TestParseAndEvaluationOfNotAllowedNestedTag() { try { Base().Parse( "<c:choose><c:when test=\"true\">a</c:when><c:when test=\"true\">b</c:when><c:out>c</c:out></c:choose>"); Assert.Fail("Expected exception"); } catch (TagException Te) { Assert.That(Te.MessageWithOutContext, Is.EqualTo( TagException.OnlyNestedTagsOfTypeAllowed(typeof(Out), typeof(When), typeof(Otherwise)) .Message)); } }
public void TestGetOfMessageWithWrongNestedType() { var model = new TagModel(new object()); model.PushTagStack(); model.Tag[FormatConstants.BUNDLE] = new ResourceBundle("FormatTags/compiled", ""); model.Page[FormatConstants.LOCALE] = new CultureInfo("en-US"); var tag = new Message(); tag.Key = new MockAttribute(new Constant("c")); try { tag.AddNestedTag(new Out()); } catch (TagException Te) { Assert.That(Te.Message, Is.EqualTo(TagException.OnlyNestedTagsOfTypeAllowed(typeof(Out), typeof(Param)).Message)); } }