Beispiel #1
0
 public void SetUp()
 {
     _lib = new TagLib();
     _lib.Register(new Tags.Tiles());
     _lib.Register(new Sharp());
     _factory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory;
     new TilesSet();
     _map              = new TilesMap();
     _data             = new Hashtable();
     _model            = new TagModel(_data);
     _nestedAttributes = new AttributeSet(
         "nested",
         new TileAttribute("aAttribute", new StringTile("aAttributeValue"))
         );
     _map.AddTile(new TemplateTile("fileWithAttributes", _factory.Handle("filewithtileattributes.htm", true), _nestedAttributes));
     _attributes = new AttributeSet(
         "main",
         new TileAttribute("simple", new StringTile("simpleValue")),
         new TileAttribute("file", new TemplateTile(null, _factory.Handle("a.htm", true), null)),
         new TileAttribute("fileWithVars", new TemplateTile(null, _factory.Handle("b.htm", true), null)),
         new TileAttribute("fileWithTilesAttributes", new TileReference("fileWithAttributes", _map))
         );
     _model.Decorate().With(_attributes);
     _data["simpleAsProperty"] = "simple";
     _data["some"]             = new Hashtable {
         { "a", "AA" }
     };
 }
Beispiel #2
0
        public void TestCache()
        {
            var   ts = new TilesSet();
            ITile a  = new TemplateTile("a", _factory.Handle("a.htm", true), new List <TileAttribute>());
            ITile b  = new TemplateTile("b", _factory.Handle("b.htm", true), new List <TileAttribute>());

            ts.Map.AddTile(a);
            ts.Map.AddTile(b);

            Assert.That(ts["a"], Is.SameAs(a));
            Assert.That(ts["b"], Is.SameAs(b));
        }
        public void ErrorFileShouldSaveParseContext()
        {
            var lib = new TagLib();

            lib.Register(new Tags.Tiles());
            lib.Register(new Sharp());
            var factory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory;

            try
            {
                new TilesSet();
                var tile = new TemplateTile(
                    "test",
                    factory.Handle("errorinfile.htm", true),
                    null
                    );
            }
            catch (TemplateExceptionWithContext TEWC)
            {
                Assert.That(TEWC.Context, Is.Not.Null);
                Assert.That(TEWC.Context.LineNumber, Is.EqualTo(2));
                string       fullPath     = Path.GetFullPath("errorinfile.htm");
                TagException tagException =
                    TagException.UnbalancedCloseingTag(new ForEach()
                {
                    Group = new Core()
                }, new If()
                {
                    Group = new Core()
                }).Decorate(TEWC.Context);
                Assert.That(TEWC.Message,
                            Is.EqualTo(TemplateExceptionWithContext.ErrorInTemplate(fullPath, tagException).Message));
            }
        }
Beispiel #4
0
        public void HandNestedIncludeWithParentDirs()
        {
            ITile a      = new TemplateTile("a", _factory.Handle("Home/Index.htm", true), new List <TileAttribute>());
            var   result = a.Render(new TagModel(new Dictionary <string, string> {
                { "Message", "Test" }
            }));
            string expected = File.ReadAllText("expected_insert_template.htm");

            result   = CleanUp(result);
            expected = CleanUp(expected);
            Assert.That(result, Is.EqualTo(expected));
        }