Ejemplo n.º 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));
     }
 }
Ejemplo n.º 2
0
 public void SetUp()
 {
     _lib = new TagLib();
     _lib.Register(new Tags.Tiles());
     _lib.Register(new Sharp());
     _factory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory;
 }
        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"));
        }
Ejemplo n.º 4
0
        public IResourceLocatorFactory CloneForTagLib(ITagLib lib)
        {
            var f = new FileLocatorFactory(_filePath, _filePrefix)
            {
                _lib = lib ?? _lib
            };

            return(f);
        }
Ejemplo n.º 5
0
 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"));
 }
Ejemplo n.º 6
0
 public void SetUp()
 {
     _lib = new TagLib();
     _lib.Register(new Tags.Tiles());
     _lib.Register(new Sharp());
     _factory = new FileLocatorFactory().CloneForTagLib(_lib) as FileLocatorFactory;
     _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"}};
 }
Ejemplo n.º 7
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
        }
Ejemplo n.º 8
0
 public IResourceLocatorFactory CloneForTagLib(ITagLib lib)
 {
     var f = new FileLocatorFactory(_filePath,_filePrefix) {_lib=lib??_lib};
     return f;
 }
 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);
 }