Beispiel #1
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);
     }
 }
        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));
            }
        }