Exemplo n.º 1
0
        public void BugSequenceContainsNo()
        {
            var model = new Hashtable();

            model.Add("small", 3);
            model.Add("large", 11);
            model.Add("text", "some text");
            model.Add("greet", "Hello");
            model.Add("to", "world");

            var list = new ArrayList(new[] { "H1", "H2", "H3" });

            model.Add("list", list);


            try
            {
                Formatter formatter = Formatter.FileBasedFormatter("bugsequencenoelement.htm",
                                                                   TagLibMode.StrictResolve,
                                                                   new TagLib(TagLibMode.StrictResolve, new Core(), new Format()));
            }
            catch (ExceptionWithContext Pe)
            {
                Assert.That(Pe.MessageWithOutContext, Text.StartsWith(TagException.UnkownTag("h1").Message));
            }
        }
Exemplo n.º 2
0
            public ITag Get(string name, ParseContext context)
            {
                var tag = _tags.FirstOrDefault(t => t.TagName.Equals(name));

                if (tag != null)
                {
                    return(tag);
                }
                throw TagException.UnkownTag(name).Decorate(context);
            }
        protected override ITag ParseTagType()
        {
            var tag = base.ParseTagType();

            if (tag == null)
            {
                throw TagException.UnkownTag(_helper.Current.Contents, TagNames).Decorate(_helper.Current);
            }
            return(tag);
        }
Exemplo n.º 4
0
        public void Should_Throw_Correct_Error_Message_On_Unknown_Tag()
        {
            const string TEMPLATE = "<choose><unknown></unknown><otherwise></otherwise></choose>";
            var          model    = new TestModel();

            try
            {
                var formatter = new Formatter(TEMPLATE).SwitchToMode(TagLibMode.RelaxedResolve).Parse();
                Assert.Fail("Expected exception");
            }
            catch (TagException Te)
            {
                Assert.That(Te.MessageWithOutContext, Text.StartsWith(TagException.UnkownTag("unknown").Message));
            }
        }
Exemplo n.º 5
0
        protected override ITag ParseTagType()
        {
            Token group;
            Token name;

            group = _helper.Read(TokenType.Regular);
            if (_helper.IsAhead(TagLibConstants.GROUP_TAG_SEPERATOR))
            {
                _helper.Read(TagLibConstants.GROUP_TAG_SEPERATOR);
                name = _helper.Read(TokenType.Regular);
                if (_helper.IgnoreUnkownTag() && !_lib.Exists(group.Contents))
                {
                    return(null);
                }
                ITagGroup tagGroup = _lib.Get(group.Contents, group.Context);
                return(tagGroup.Get(name));
            }

            name = group;
            var hits = new List <ITag>();
            var libs = new HashSet <ITagGroup>();

            foreach (var lib in _lib)
            {
                if (!lib.Exist(name))
                {
                    continue;
                }
                hits.Add(lib.Get(name));
                libs.Add(lib);
            }
            if (hits.Count == 0)
            {
                if (_helper.IgnoreUnkownTag())
                {
                    return(null);
                }
                throw TagException.UnkownTag(name.Contents, TagNames).Decorate(name.Context);
            }
            return(hits.First());
        }