Example #1
0
 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));
     }
 }
        public void CreateShouldAssembleFileTileWithCorrectExtendsAndPath()
        {
            var lib = new TagLib();
            lib.Register(new Tags.Tiles());
            lib.Register(new Sharp());
            var locatorFactory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory;
            var factory = new TilesFactory( new MockConfiguration("a", DateTime.Now) {Factory = locatorFactory });

            var entry = new MockTileEntry
                            {
                                Name = "name",
                                Path = "b.htm",
                                Extends = "definition"
                            };
            ITile tile = new TemplateOverridingDefinitionTileCreator().Create(entry, factory);
            Assert.That(tile, Is.Not.Null);
            Assert.That(tile.GetType(), Is.EqualTo(typeof(TemplateOveridingDefinitionTile)));
            Assert.That(tile.Name, Is.EqualTo("name"));

            var definition = (TemplateOveridingDefinitionTile)tile;
            var tileTemplate = (FileTemplate)definition.Template;

            Assert.That(tileTemplate.Path.EndsWith("b.htm"));

            Assert.That(definition.Extends, Is.Not.Null);
            Assert.That(definition.Extends.GetType(), Is.EqualTo(typeof (TileReference)));

            var reference = (TileReference) definition.Extends;
            Assert.That(reference.Name, Is.EqualTo("definition"));
        }
 public DocumentationGenerator()
 {
     _lib = new TagLib();
     _lib.Register(new Sharp());
     _subject = _lib;
     _all = true;
     _fragment = false;
     //            FunctionLib.Register(new MathFunctionLib());
     _specials = new List<Func<ITag, TagDocumentation, bool>>();
 }
Example #4
0
        public DocumentModel(TagLib subject, bool all, ResourceBundle bundle, IList<Func<ITag, TagDocumentation, bool>> specials=null)
        {
            _expressionlib = new ExpressionLib();

            _subject = subject;
            _all = all;
            _specials = specials??new List<Func<ITag, TagDocumentation, bool>>();
            _additionalResources = new Dictionary<string, string>();
            _resouceKey = new ResourceKeyStack(bundle);
            GatherExpressions();
            GatherFunctions();
            GatherGroups();
        }
Example #5
0
        static TemplateField()
        {
            TagLib = new TagLib();

            TilesConfigurationSection config = TilesConfigurationSection.Get();
            var prefix = TemplateFieldPrefixHelper.BuildPrefix(HostingEnvironment.ApplicationPhysicalPath, config.FilePrefix);
            RefreshJob.REFRESH_INTERVAL = config.RefreshIntervalSeconds;
            _configuration = new TileXmlConfigurator(
                TagLib,
                config.ConfigFilePath,
                prefix
                );
            TILES = new TilesSet(_configuration);
        }
 public void CreateShouldAssembleFileTileWithCorrectPath()
 {
     var lib = new TagLib();
     lib.Register(new Tags.Tiles());
     lib.Register(new Sharp());
     var locatorFactory = new FileLocatorFactory().CloneForTagLib(lib) as FileLocatorFactory;
     var factory = new TilesFactory(new MockConfiguration("x", DateTime.Now) {Factory = locatorFactory });
     var entry = new MockTileEntry
                     {
                         Name = "name",
                         Path = "a.htm",
                         Extends = null
                     };
     var tile = new TemplateTileCreator().Create(entry, factory);
     Assert.That(tile, Is.Not.Null);
     Assert.That(tile.GetType(), Is.EqualTo(typeof (TemplateTile)));
     Assert.That(tile.Name, Is.EqualTo("name"));
     var templateTile = (TemplateTile) tile;
     var fileTemplate = (FileTemplate) templateTile.Template;
     Assert.That(fileTemplate.Path.EndsWith("a.htm"));
 }
Example #7
0
 public void Push(params ITagGroup[] extension)
 {
     var dish = new TagLib(Mode,extension);
     _stack.Push(dish);
 }
Example #8
0
        public Formatter SwitchToMode(TagLibMode mode)
        {
            if (_templateParsed != null)
                throw new InvalidOperationException("SwitchToMode can only be called before calling Parse!");

            var lib=new TagLib(mode,_lib.ToArray());
            _lib = lib;
            return this;
        }
Example #9
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" } };
 }
 public void SetUp()
 {
     _lib = new TagLib();
     _lib.Register(new Tags.Tiles());
     _lib.Register(new Sharp());
     _locatorFactory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory;
 }
Example #11
0
        public void GetView_Should_Update_Locator_Correct()
        {
            //Given
            var lib = new TagLib();
            lib.Register(new Html());
            lib.Register(new Tiles.Tags.Tiles());

            var factory = new FileLocatorFactory("Views").CloneForTagLib(lib);
            var cache = new NstlCache { Factory = factory };
            var view = cache.GetView("Home/Index.htm");
            Assert.That(view, Is.Not.Null);
            var model = new TagModel(new Dictionary<string, string> { { "Message", "Test" } });
            Assert.That(view.Render(model).Contains("VIEWS"));
            //Then
        }
Example #12
0
 public void CheckPassThroughOfContentParsed()
 {
     var lib = new TagLib().Register(new Sharp());
     ITag tag = new TagLibParserFactory(new TagLibForParsing(lib), new ExpressionLib(), new FileLocatorFactory(), null).Parse("<sharp:marker id='id'>body</sharp:marker>");
     Assert.That(tag.Evaluate(new TagModel(this)), Is.EqualTo("body"));
 }
 public DocumentationGenerator For(TagLib subject)
 {
     _subject = subject;
     return this;
 }
Example #14
0
 private static TagLib BuildTagLib()
 {
     var tagLib = new TagLib();
     tagLib.Register(new Html());
     return tagLib;
 }
Example #15
0
 private static TagLibParserFactory CreateFactory()
 {
     var lib = new TagLib();
     lib.Register(new Sharp());
     return new TagLibParserFactory(new TagLibForParsing(lib), new ExpressionLib(), new FileLocatorFactory(), null);
 }
 public void SetUp()
 {
     _lib = new TagLib();
     _lib.Register(new Tags.Tiles());
     _lib.Register(new Sharp());
     _locatorFactory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory;
     var config = new MockConfiguration() {Factory = _locatorFactory };
     _factory = new TilesFactory(config);
 }