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); } }
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); } }
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(); }
public TileAttribute this[string name] { get { try { return(Attributes[name]); } catch (KeyNotFoundException) { throw TileException.AttributeNotFound(name, _definitionName); } } }
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)); } }
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); } }
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)); } }
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)); } }
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)); } }
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 ) ); } }