public void CanStoreAndRetrieveComponent() { var component = new MockComponent(); _entity.Add(component); Assert.AreSame(_entity.Get(typeof(MockComponent)), component); }
public void CanRemoveComponent() { var component = new MockComponent(); _entity.Add(component); _entity.Remove(typeof(MockComponent)); Assert.IsFalse(_entity.Has(typeof(MockComponent))); }
public void AddReturnsReferenceToEntity() { var component = new MockComponent(); var e = _entity.Add(component); Assert.AreSame(_entity, e); }
public void CanReplaceComponent() { var component1 = new MockComponent(); _entity.Add(component1); var component2 = new MockComponent(); _entity.Add(component2); Assert.AreEqual(_entity.Get(typeof(MockComponent)), component2); }
public void ComponentAddedSignalContainsCorrectType() { Type type = null; var component = new MockComponent(); _entity.ComponentAdded += (entity, componentType) => type = componentType; _entity.Add(component); Assert.AreEqual(typeof(MockComponent), type); }
public void CanStoreAndRetrieveMultipleComponents() { var component1 = new MockComponent(); _entity.Add(component1); var component2 = new MockComponent2(); _entity.Add(component2); Assert.AreSame(_entity.Get(typeof(MockComponent)), component1); Assert.AreSame(_entity.Get(typeof(MockComponent2)), component2); }
public void CanStoreBaseAndExtendedComponents() { var component1 = new MockComponent(); _entity.Add(component1); var component2 = new MockComponentExtended(); _entity.Add(component2); Assert.AreEqual(_entity.Get(typeof(MockComponent)), component1); Assert.AreEqual(_entity.Get(typeof(MockComponentExtended)), component2); }
public void StoringComponentTriggersAddedSignal() { var eventFired = false; var component = new MockComponent(); _entity.ComponentAdded += (entity, componentType) => eventFired = true; _entity.Add(component); Assert.IsTrue(eventFired); }
public void RemovingComponentTriggersRemovedSignal() { var eventFired = false; var component = new MockComponent(); _entity.Add(component); _entity.ComponentRemoved += (entity, componentType) => eventFired = true; _entity.Remove(typeof(MockComponent)); Assert.IsTrue(eventFired); }
public void CloneChildComponentHasSameProperties() { var component = new MockComponent { Value = 5 }; _entity.Add(component); var clone = _entity.Clone(); Assert.AreEqual(5, clone.Get <MockComponent>(typeof(MockComponent)).Value); }
public void ComponentRemovedSignalContainsEntityWithRemovedComponent() { var component = new MockComponent { Value = 10 }; _entity.ComponentRemoved += (entity, componentType) => component = (MockComponent)entity.Get(componentType); _entity.Add(component); _entity.Remove(typeof(MockComponent)); Assert.IsNull(component); }
public void ComponentAddedSignalEnablesAccessToComponentValue() { var value = 0; var component = new MockComponent { Value = 10 }; _entity.ComponentAdded += (entity, componentType) => value = ((MockComponent)entity.Get(componentType)).Value; _entity.Add(component); Assert.AreEqual(10, value); }
public void WillRetrieveAllComponents() { var component1 = new MockComponent(); _entity.Add(component1); var component2 = new MockComponent2(); _entity.Add(component2); var all = _entity.GetAll(); Assert.AreEqual(new List <object> { component1, component2 }, all); }
public void ComponentRemovedSignalContainsCorrectType() { Type type = null; var component = new MockComponent(); _entity.ComponentRemoved += (entity, componentType) => type = componentType; _entity.Add(component); _entity.Remove(typeof(MockComponent)); Assert.AreEqual(typeof(MockComponent), type); }
public void WillRetrieveAllComponents() { var component1 = new MockComponent(); _entity.Add(component1); var component2 = new MockComponent2(); _entity.Add(component2); var all = _entity.GetAll(); Assert.AreEqual(new List<object> { component1, component2 }, all); }
public void CloneChildComponentHasSameProperties() { var component = new MockComponent { Value = 5 }; _entity.Add(component); var clone = _entity.Clone(); Assert.AreEqual(5, clone.Get<MockComponent>(typeof(MockComponent)).Value); }