public void InsertProperty() { Item = new DummyItem(resolver, Pos); CountProperties(Item, 0); Assert.AreEqual(false, Item.ContainsProperty <DummyProperty>()); Assert.AreEqual(null, Item.GetProperty <DummyProperty>()); DummyProperty prop = new DummyProperty(Item); Assert.AreEqual(null, prop.Item); // Insert Property Item.AddProperty(prop); CountProperties(Item, 1); Assert.AreEqual(Item, prop.Item); Assert.AreEqual(true, Item.ContainsProperty <DummyProperty>()); Assert.AreEqual(prop, Item.GetProperty <DummyProperty>()); // Insert Property again try { Item.AddProperty(prop); throw new Exception("Should throw an Exception"); } catch (InvalidOperationException) { } // insert a Property of the same Type DummyProperty prop2 = new DummyProperty(Item); try { Item.AddProperty(prop2); throw new Exception("Should throw an Exception"); } catch (InvalidOperationException) { } // Insert Property into running Engine. Item = new DummyItem(resolver, Pos); Engine.InsertItem(Item); prop = new DummyProperty(Item); try { Item.AddProperty(prop); throw new Exception("Should throw an Exception"); } catch (InvalidOperationException) { } }
public void InsertProperty() { Item = new DummyItem(resolver, Pos); CountProperties(Item, 0); Assert.AreEqual(false, Item.ContainsProperty<DummyProperty>()); Assert.AreEqual(null, Item.GetProperty<DummyProperty>()); DummyProperty prop = new DummyProperty(Item); Assert.AreEqual(null, prop.Item); // Insert Property Item.AddProperty(prop); CountProperties(Item, 1); Assert.AreEqual(Item, prop.Item); Assert.AreEqual(true, Item.ContainsProperty<DummyProperty>()); Assert.AreEqual(prop, Item.GetProperty<DummyProperty>()); // Insert Property again try { Item.AddProperty(prop); throw new Exception("Should throw an Exception"); } catch (InvalidOperationException) { } // insert a Property of the same Type DummyProperty prop2 = new DummyProperty(Item); try { Item.AddProperty(prop2); throw new Exception("Should throw an Exception"); } catch (InvalidOperationException) { } // Insert Property into running Engine. Item = new DummyItem(resolver, Pos); Engine.InsertItem(Item); prop = new DummyProperty(Item); try { Item.AddProperty(prop); throw new Exception("Should throw an Exception"); } catch (InvalidOperationException) { } }