Exemplo n.º 1
0
 public string Render(TagModel model, AttributeSet attributes)
 {
     try
     {
         using (model.Decorate().With(attributes))
         {
             return(_template.Evaluate(model));
         }
     }
     catch (TileExceptionWithContext)
     {
         throw;
     }
     catch (TileException)
     {
         throw;
     }
     catch (ExceptionWithContext EWC)
     {
         throw TileExceptionWithContext.ErrorInTile(_template.Description, EWC);
     }
     catch (Exception e)
     {
         throw TileException.ErrorInTile(_template.Description, e);
     }
 }
Exemplo n.º 2
0
        public string Evaluate(TagModel model)
        {
            var tileName = GetAutoValueAsString("Template", model);

            try
            {
                LoadTile(model, tileName);
                return(_tile.Render(model) ?? String.Empty);
            }
            catch (TileExceptionWithContext)
            {
                throw;
            }
            catch (TileException)
            {
                throw;
            }
            catch (ExceptionWithContext EWC)
            {
                throw TileExceptionWithContext.ErrorInTile(tileName, EWC);
            }
            catch (Exception e)
            {
                throw TileException.ErrorInTile(tileName, e);
            }
        }
Exemplo n.º 3
0
        public void TileTileException()
        {
            try
            {
                TileException tileException  = new TileException(string.Empty);
                TileException tileException2 = new TileException(string.Empty, null);
            }
            catch (Exception exception) { Assert.Fail(exception.Message); }

            Assert.Pass();
        }
Exemplo n.º 4
0
 public TileAttribute this[string name]
 {
     get
     {
         try
         {
             return(Attributes[name]);
         }
         catch (KeyNotFoundException)
         {
             throw TileException.AttributeNotFound(name, _definitionName);
         }
     }
 }
Exemplo n.º 5
0
        public void AnExceptionShouldBeThrownWhenEnteringWithTheSameName()
        {
            var   ts = new TilesMap();
            ITile a  = new MockTile("a");
            ITile b  = new MockTile("a");

            ts.AddTile(a);
            try
            {
                ts.AddTile(b);
                Assert.Fail("Expected exception");
            } catch (TileException Te)
            {
                Assert.That(Te.Message, Is.EqualTo(TileException.DoubleDefinition("a").Message));
            }
        }
Exemplo n.º 6
0
 private void AddAttributes(IEnumerable <TileAttribute> attributes, bool throwExceptionOnDoubles)
 {
     foreach (TileAttribute attribute in attributes)
     {
         string name = attribute.Name;
         if (_attributes.ContainsKey(name))
         {
             if (throwExceptionOnDoubles)
             {
                 throw TileException.AttributeNameAlreadyUsed(name, _definitionName);
             }
             continue;
         }
         _attributes.Add(name, attribute);
     }
 }
Exemplo n.º 7
0
        public void OnNonExistingAttributgesTagShouldThrowException()
        {
            var tag = new Insert
            {
                Name = new MockAttribute(new Constant("nonexisting"))
            };

            try
            {
                tag.Evaluate(_model);
                Assert.Fail("Expect exception");
            }
            catch (TileExceptionWithContext Te)
            {
                Assert.That(Te.Message, Is.EqualTo(TileException.AttributeNotFound("nonexisting", "main").Message));
            }
        }
Exemplo n.º 8
0
        public void TileAttributesShouldThrowExceptionOnNonExistingName()
        {
            var firstTile  = new TileAttribute("first", new StringTile("1"));
            var secondTile = new TileAttribute("second", new StringTile("2"));
            var set        = new AttributeSet("TILE", new List <TileAttribute> {
                firstTile, secondTile
            });

            try
            {
                Assert.That(set["nonexisting"], Is.Not.Null);
                Assert.Fail("Expected exception");
            } catch (TileException Te)
            {
                Assert.That(Te.Message, Is.EqualTo(TileException.AttributeNotFound("nonexisting", "TILE").Message));
            }
        }
Exemplo n.º 9
0
        public void TileAttributesShouldThrowExceptionWhenAddingTheSameName()
        {
            var firstTile  = new TileAttribute("first", new StringTile("1"));
            var secondTile = new TileAttribute("first", new StringTile("2"));

            try
            {
                new AttributeSet("TILE", new List <TileAttribute> {
                    firstTile, secondTile
                });
                Assert.Fail("Expected exception");
            }
            catch (TileException Te)
            {
                Assert.That(Te.Message, Is.EqualTo(TileException.AttributeNameAlreadyUsed("first", "TILE").Message));
            }
        }
Exemplo n.º 10
0
 public void DeserializeFromAssemlbyWithDoubleEntriesShouldThrowException()
 {
     try
     {
         new TilesSet(new TileXmlConfigurator(_lib, "Configuration/tiles.double.config.xml"));
         Assert.Fail("Expected exception");
     }
     catch (TileException e)
     {
         Assert.That(
             e.Message,
             Is.EqualTo(
                 TileException.DoubleDefinition(
                     "b"
                     ).Message
                 )
             );
     }
 }