public void RemovePrototype() { Entity entity = new Entity(); Entity prototype = new Entity() { Name = "prototype" }; entity.AddPrototype(prototype); entity.RemovePrototype(prototype); Assert.AreEqual(0, entity.Prototypes.Where(x => x.Name == "prototype").Count()); }
public void EventRemovedAfterRemovePrototype() { int eventsFired = 0; Entity parent = new Entity() { Name = "parent" }; Entity child = new Entity(); child.Events.CollectionChanged += (o, e) => eventsFired++; child.AddPrototype(parent); Event parentEvent = new Event(Workspace.Instance.GetPlugin(TriggerOccursEventType)); parent.AddEvent(parentEvent); child.RemovePrototype(parent); Assert.AreEqual(2, eventsFired); Assert.AreEqual(1, parent.Events.Count); Assert.AreEqual(0, child.Events.Count); }
public void AttributeBecomesNonInheritableAfterPrototypeChange() { Entity parent = new Entity() { Name = "parent" }; Entity parentWithAttribute = new Entity() { Name = "parentWithAttribute" }; Attribute attribute = new Attribute("test") { Value = new Value("new value") }; parentWithAttribute.AddAttribute(attribute); Entity child = new Entity(); child.AddPrototype(parentWithAttribute); Attribute childAttribute = child.GetAttribute("test"); //childAttribute.IsInherited = false; childAttribute.Value = new Value("value"); //Assert.IsTrue(childAttribute.CanInherit); child.RemovePrototype(parentWithAttribute); //Assert.IsFalse(childAttribute.CanInherit); Assert.AreEqual(1, parentWithAttribute.Attributes.Count); Assert.AreEqual(1, child.Attributes.Count); }