void assertHasNotComponentA(Entity e) { var components = e.GetComponents(); components.Length.should_be(0); var indices = e.GetComponentIndices(); indices.Length.should_be(0); e.HasComponentA().should_be_false(); e.HasComponents(_indicesA).should_be_false(); e.HasAnyComponent(_indicesA).should_be_false(); }
void assertHasComponentA(Entity e, IComponent component = null) { if (component == null) { component = Component.A; } e.GetComponentA().should_be_same(component); var components = e.GetComponents(); components.Length.should_be(1); components.should_contain(component); var indices = e.GetComponentIndices(); indices.Length.should_be(1); indices.should_contain(CID.ComponentA); e.HasComponentA().should_be_true(); e.HasComponents(_indicesA).should_be_true(); e.HasAnyComponent(_indicesA).should_be_true(); }
void when_created() { Entity e = null; before = () => { e = this.CreateEntity(); }; context["initial state"] = () => { it["throws when attempting to get component of type which hasn't been added"] = expect <EntityDoesNotHaveComponentException>(() => { e.GetComponentA(); }); it["gets empty array of components when no components were added"] = () => { e.GetComponents().should_be_empty(); }; it["gets empty array of component indices when no components were added"] = () => { e.GetComponentIndices().should_be_empty(); }; it["doesn't have component of type when no component of that type was added"] = () => { e.HasComponentA().should_be_false(); }; it["doesn't have components of types when no components of these types were added"] = () => { e.HasComponents(_indicesA).should_be_false(); }; it["doesn't have any components of types when no components of these types were added"] = () => { e.HasAnyComponent(_indicesA).should_be_false(); }; it["returns entity when adding a component"] = () => { e.AddComponent(0, null).should_be_same(e); }; it["adds a component"] = () => { e.AddComponentA(); assertHasComponentA(e); }; it["throws when attempting to remove a component of type which hasn't been added"] = expect <EntityDoesNotHaveComponentException>(() => { e.RemoveComponentA(); }); it["replacing a non existing component adds component"] = () => { e.ReplaceComponentA(Component.A); assertHasComponentA(e); }; }; context["when component added"] = () => { before = () => { e.AddComponentA(); }; it["throws when adding a component of the same type twice"] = expect <EntityAlreadyHasComponentException>(() => { e.AddComponentA(); e.AddComponentA(); }); it["returns entity when removing a component"] = () => { e.RemoveComponent(CID.ComponentA).should_be_same(e); }; it["removes a component of type"] = () => { e.RemoveComponentA(); assertHasNotComponentA(e); }; it["returns entity when replacing a component"] = () => { e.ReplaceComponent(CID.ComponentA, null).should_be_same(e); }; it["replaces existing component"] = () => { var newComponentA = new ComponentA(); e.ReplaceComponentA(newComponentA); assertHasComponentA(e, newComponentA); }; it["doesn't have components of types when not all components of these types were added"] = () => { e.HasComponents(_indicesAB).should_be_false(); }; it["has any components of types when any component of these types was added"] = () => { e.HasAnyComponent(_indicesAB).should_be_true(); }; context["when adding another component"] = () => { before = () => { e.AddComponentB(); }; it["gets all components"] = () => { var components = e.GetComponents(); components.Length.should_be(2); components.should_contain(Component.A); components.should_contain(Component.B); }; it["gets all component indices"] = () => { var componentIndices = e.GetComponentIndices(); componentIndices.Length.should_be(2); componentIndices.should_contain(CID.ComponentA); componentIndices.should_contain(CID.ComponentB); }; it["has other component"] = () => { e.HasComponentB().should_be_true(); }; it["has components of types when all components of these types were added"] = () => { e.HasComponents(_indicesAB).should_be_true(); }; it["removes all components"] = () => { e.RemoveAllComponents(); e.HasComponentA().should_be_false(); e.HasComponentB().should_be_false(); e.GetComponents().should_be_empty(); e.GetComponentIndices().should_be_empty(); }; it["can ToString"] = () => { e.AddComponent(0, new SomeComponent()); e.ToString().should_be("Entity_0(Some, ComponentA, ComponentB)"); }; }; }; context["events"] = () => { int didDispatch = 0; before = () => { didDispatch = 0; }; it["dispatches OnComponentAdded when adding a component"] = () => { e.OnComponentAdded += (entity, index, component) => { didDispatch += 1; entity.should_be_same(e); index.should_be(CID.ComponentA); component.should_be_same(Component.A); }; e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => this.Fail(); e.AddComponentA(); didDispatch.should_be(1); }; it["dispatches OnComponentRemoved when removing a component"] = () => { e.AddComponentA(); e.OnComponentRemoved += (entity, index, component) => { didDispatch += 1; entity.should_be_same(e); index.should_be(CID.ComponentA); component.should_be_same(Component.A); }; e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => this.Fail(); e.RemoveComponentA(); didDispatch.should_be(1); }; it["dispatches OnComponentReplaced when replacing a component"] = () => { e.AddComponentA(); var newComponentA = new ComponentA(); e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => { didDispatch += 1; entity.should_be_same(e); index.should_be(CID.ComponentA); previousComponent.should_be_same(Component.A); newComponent.should_be_same(newComponentA); }; e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.ReplaceComponentA(newComponentA); didDispatch.should_be(1); }; it["provides previous and new component OnComponentReplaced when replacing with different component"] = () => { var prevComp = new ComponentA(); var newComp = new ComponentA(); e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => { didDispatch += 1; entity.should_be_same(e); previousComponent.should_be_same(prevComp); newComponent.should_be_same(newComp); }; e.AddComponent(CID.ComponentA, prevComp); e.ReplaceComponent(CID.ComponentA, newComp); didDispatch.should_be(1); }; it["provides previous and new component OnComponentReplaced when replacing with same component"] = () => { e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => { didDispatch += 1; entity.should_be_same(e); previousComponent.should_be_same(Component.A); newComponent.should_be_same(Component.A); }; e.AddComponentA(); e.ReplaceComponentA(Component.A); didDispatch.should_be(1); }; it["doesn't dispatch anything when replacing a non existing component with null"] = () => { e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.ReplaceComponentA(null); }; it["dispatches OnComponentAdded when attempting to replace a component which hasn't been added"] = () => { var newComponentA = new ComponentA(); e.OnComponentAdded += (entity, index, component) => { didDispatch += 1; entity.should_be_same(e); index.should_be(CID.ComponentA); component.should_be_same(newComponentA); }; e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.ReplaceComponentA(newComponentA); didDispatch.should_be(1); }; it["dispatches OnComponentRemoved when replacing a component with null"] = () => { e.AddComponentA(); e.OnComponentRemoved += (entity, index, component) => { didDispatch += 1; }; e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, previousComponent, newComponent) => this.Fail(); e.ReplaceComponentA(null); didDispatch.should_be(1); }; it["dispatches OnComponentRemoved when removing all components"] = () => { e.AddComponentA(); e.AddComponentB(); e.OnComponentRemoved += (entity, index, component) => didDispatch += 1; e.RemoveAllComponents(); didDispatch.should_be(2); }; }; context["reference counting"] = () => { it["retains entity"] = () => { e.RefCount().should_be(0); e.Retain(); e.RefCount().should_be(1); }; it["releases entity"] = () => { e.Retain(); e.Release(); e.RefCount().should_be(0); }; it["throws when releasing more than it has been retained"] = expect <EntityIsAlreadyReleasedException>(() => { e.Retain(); e.Release(); e.Release(); }); context["events"] = () => { it["doesn't dispatch OnEntityReleased when retaining"] = () => { e.OnEntityReleased += entity => this.Fail(); e.Retain(); }; it["dispatches OnEntityReleased when retain and release"] = () => { var didDispatch = 0; e.OnEntityReleased += entity => { didDispatch += 1; entity.should_be_same(e); }; e.Retain(); e.Release(); }; }; }; context["internal caching"] = () => { context["components"] = () => { IComponent[] cache = null; before = () => { e.AddComponentA(); cache = e.GetComponents(); }; it["caches components"] = () => { e.GetComponents().should_be_same(cache); }; it["updates cache when a new component was added"] = () => { e.AddComponentB(); e.GetComponents().should_not_be_same(cache); }; it["updates cache when a component was removed"] = () => { e.RemoveComponentA(); e.GetComponents().should_not_be_same(cache); }; it["updates cache when a component was replaced"] = () => { e.ReplaceComponentA(new ComponentA()); e.GetComponents().should_not_be_same(cache); }; it["doesn't update cache when a component was replaced with same component"] = () => { e.ReplaceComponentA(Component.A); e.GetComponents().should_be_same(cache); }; it["updates cache when all components were removed"] = () => { e.RemoveAllComponents(); e.GetComponents().should_not_be_same(cache); }; }; context["component indices"] = () => { int[] cache = null; before = () => { e.AddComponentA(); cache = e.GetComponentIndices(); }; it["caches component indices"] = () => { e.GetComponentIndices().should_be_same(cache); }; it["updates cache when a new component was added"] = () => { e.AddComponentB(); e.GetComponentIndices().should_not_be_same(cache); }; it["updates cache when a component was removed"] = () => { e.RemoveComponentA(); e.GetComponentIndices().should_not_be_same(cache); }; it["doesn't update cache when a component was replaced"] = () => { e.ReplaceComponentA(new ComponentA()); e.GetComponentIndices().should_be_same(cache); }; it["updates cache when adding a new component with ReplaceComponent"] = () => { e.ReplaceComponentC(Component.C); e.GetComponentIndices().should_not_be_same(cache); }; it["updates cache when all components were removed"] = () => { e.RemoveAllComponents(); e.GetComponentIndices().should_not_be_same(cache); }; }; context["ToString"] = () => { context["when component was added"] = () => { string cache = null; before = () => { e.AddComponentA(); cache = e.ToString(); }; it["caches entity description"] = () => { e.ToString().should_be_same(cache); }; it["updates cache when a new component was added"] = () => { e.AddComponentB(); e.ToString().should_not_be_same(cache); }; it["updates cache when a component was removed"] = () => { e.RemoveComponentA(); e.ToString().should_not_be_same(cache); }; it["doesn't update cache when a component was replaced"] = () => { e.ReplaceComponentA(new ComponentA()); e.ToString().should_be_same(cache); }; it["updates cache when all components were removed"] = () => { e.RemoveAllComponents(); e.ToString().should_not_be_same(cache); }; }; it["updates cache when RemoveAllComponents is called, even if entity has no components"] = () => { var str = e.ToString(); e.RemoveAllComponents(); e.ToString().should_not_be_same(str); }; }; }; }
void when_created() { Entity e = null; before = () => { e = this.CreateEntity(); }; it["has component of type when component of that type was added"] = () => { e.AddComponentA(); e.HasComponentA().should_be_true(); }; it["returns entity when adding a component"] = () => { e.AddComponent(0, null).should_be_same(e); }; it["doesn't have component of type when no component of that type was added"] = () => { e.HasComponentA().should_be_false(); }; it["doesn't have components of types when no components of these types were added"] = () => { e.HasComponents(new [] { CID.ComponentA }).should_be_false(); }; it["doesn't have components of types when not all components of these types were added"] = () => { e.AddComponentA(); e.HasComponents(new [] { CID.ComponentA, CID.ComponentB }).should_be_false(); }; it["has components of types when all components of these types were added"] = () => { e.AddComponentA(); e.AddComponentB(); e.HasComponents(new [] { CID.ComponentA, CID.ComponentB }).should_be_true(); }; it["doesn't have any components of types when no components of these types were added"] = () => { e.HasAnyComponent(new [] { CID.ComponentA }).should_be_false(); }; it["has any components of types when any component of these types was added"] = () => { e.AddComponentA(); e.HasAnyComponent(new [] { CID.ComponentA, CID.ComponentB }).should_be_true(); }; it["removes a component of type"] = () => { e.AddComponentA(); e.RemoveComponentA(); e.HasComponentA().should_be_false(); }; it["returns entity when removing a component"] = () => { e.AddComponentA(); e.RemoveComponent(1).should_be_same(e); }; it["gets a component of type"] = () => { e.AddComponentA(); e.GetComponentA().should_be_same(Component.A); }; it["replaces existing component"] = () => { e.AddComponentA(); var newComponentA = new ComponentA(); e.ReplaceComponentA(newComponentA); e.GetComponentA().should_be_same(newComponentA); }; it["returns entity when replacing a component"] = () => { e.ReplaceComponent(1, null).should_be_same(e); }; it["replacing a non existing component adds component"] = () => { var newComponentA = new ComponentA(); e.ReplaceComponentA(newComponentA); e.GetComponentA().should_be_same(newComponentA); }; it["gets empty array of components when no components were added"] = () => { e.GetComponents().should_be_empty(); }; it["gets empty array of component indices when no components were added"] = () => { e.GetComponentIndices().should_be_empty(); }; it["gets all components"] = () => { e.AddComponentA(); e.AddComponentB(); var allComponents = e.GetComponents(); allComponents.should_contain(Component.A); allComponents.should_contain(Component.B); allComponents.Length.should_be(2); }; it["gets all component indices"] = () => { e.AddComponentA(); e.AddComponentB(); var allComponentIndices = e.GetComponentIndices(); allComponentIndices.should_contain(CID.ComponentA); allComponentIndices.should_contain(CID.ComponentB); allComponentIndices.Length.should_be(2); }; it["removes all components"] = () => { e.AddComponentA(); e.AddComponentB(); e.RemoveAllComponents(); e.HasComponentA().should_be_false(); e.HasComponentB().should_be_false(); e.GetComponents().should_be_empty(); e.GetComponentIndices().should_be_empty(); }; it["can ToString"] = () => { e.AddComponentA(); e.AddComponentB(); e.ToString().should_be("Entity_0(ComponentA, ComponentB)"); }; context["events"] = () => { Entity eventEntity = null; int eventIndex = CID.None; IComponent eventComponent = null; before = () => { eventEntity = null; eventIndex = CID.None; eventComponent = null; }; it["dispatches OnComponentAdded when adding a component"] = () => { e.OnComponentAdded += (entity, index, component) => { eventEntity = entity; eventIndex = index; eventComponent = component; }; e.OnComponentReplaced += (entity, index, component) => this.Fail(); e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.AddComponentA(); eventEntity.should_be_same(e); eventIndex.should_be(CID.ComponentA); eventComponent.should_be_same(Component.A); }; it["dispatches OnComponentRemoved when removing a component"] = () => { e.AddComponentA(); e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, component) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => { eventEntity = entity; eventIndex = index; eventComponent = component; }; e.RemoveComponentA(); eventEntity.should_be_same(e); eventIndex.should_be(CID.ComponentA); eventComponent.should_be_same(Component.A); }; it["dispatches OnComponentWillBeRemoved when removing a component"] = () => { e.AddComponentA(); e.OnComponentWillBeRemoved += (entity, index, component) => { eventEntity = entity; eventIndex = index; eventComponent = component; }; e.RemoveComponentA(); eventEntity.should_be_same(e); eventIndex.should_be(CID.ComponentA); eventComponent.should_be_same(Component.A); }; it["dispatches OnComponentReplaced when replacing a component"] = () => { e.AddComponentA(); var newComponentA = new ComponentA(); var didReplace = 0; e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, component) => { entity.should_be_same(entity); index.should_be(CID.ComponentA); component.should_be_same(newComponentA); didReplace++; }; e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.ReplaceComponentA(newComponentA); didReplace.should_be(1); }; it["doesn't dispatch anything when replacing a non existing component with null"] = () => { e.OnComponentAdded += (entity, index, component) => this.Fail(); e.OnComponentReplaced += (entity, index, component) => this.Fail(); e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); e.ReplaceComponentA(null); }; it["dispatches OnComponentWillBeRemoved when called manually and component exists"] = () => { e.AddComponentA(); e.OnComponentWillBeRemoved += (entity, index, component) => { eventEntity = entity; eventIndex = index; eventComponent = component; }; e.WillRemoveComponent(CID.ComponentA); eventEntity.should_be_same(e); eventIndex.should_be(CID.ComponentA); eventComponent.should_be_same(Component.A); }; it["doesn't dispatch OnComponentWillBeRemoved when called manually and entity doesn't have"] = () => { e.OnComponentWillBeRemoved += (entity, index, component) => { eventEntity = entity; eventIndex = index; eventComponent = component; }; e.WillRemoveComponent(CID.ComponentA); eventEntity.should_be_null(); eventIndex.should_be(CID.None); eventComponent.should_be_null(); }; it["dispatches OnComponentAdded when attempting to replace a component which hasn't been added"] = () => { e.OnComponentAdded += (entity, index, component) => { eventEntity = entity; eventIndex = index; eventComponent = component; }; e.OnComponentReplaced += (entity, index, component) => this.Fail(); e.OnComponentWillBeRemoved += (entity, index, component) => this.Fail(); e.OnComponentRemoved += (entity, index, component) => this.Fail(); var newComponentA = new ComponentA(); e.ReplaceComponentA(newComponentA); eventEntity.should_be_same(e); eventIndex.should_be(CID.ComponentA); eventComponent.should_be_same(newComponentA); }; it["dispatches OnComponentRemoved when removing all components"] = () => { var removed = 0; e.AddComponentA(); e.AddComponentB(); e.OnComponentRemoved += (entity, index, component) => removed++; e.RemoveAllComponents(); removed.should_be(2); }; }; context["invalid operations"] = () => { it["throws when adding a component of the same type twice"] = expect <EntityAlreadyHasComponentException>(() => { e.AddComponentA(); e.AddComponentA(); }); it["throws when attempting to remove a component of type which hasn't been added"] = expect <EntityDoesNotHaveComponentException>(() => { e.RemoveComponentA(); }); it["throws when attempting to get component of type which hasn't been added"] = expect <EntityDoesNotHaveComponentException>(() => { e.GetComponentA(); }); }; context["internal caching"] = () => { context["components"] = () => { it["caches components"] = () => { e.AddComponentA(); var c = e.GetComponents(); e.GetComponents().should_be_same(c); }; it["updates cache when a new component was added"] = () => { e.AddComponentA(); var c = e.GetComponents(); e.AddComponentB(); e.GetComponents().should_not_be_same(c); }; it["updates cache when a component was removed"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponents(); e.RemoveComponentA(); e.GetComponents().should_not_be_same(c); }; it["updates cache when a component was replaced"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponents(); e.ReplaceComponentA(new ComponentA()); e.GetComponents().should_not_be_same(c); }; it["doesn't update cache when a component was replaced with same component"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponents(); e.ReplaceComponentA(Component.A); e.GetComponents().should_be_same(c); }; it["updates cache when all components were removed"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponents(); e.RemoveAllComponents(); e.GetComponents().should_not_be_same(c); }; }; context["component indices"] = () => { it["caches component indices"] = () => { e.AddComponentA(); var c = e.GetComponentIndices(); e.GetComponentIndices().should_be_same(c); }; it["updates cache when a new component was added"] = () => { e.AddComponentA(); var c = e.GetComponentIndices(); e.AddComponentB(); e.GetComponentIndices().should_not_be_same(c); }; it["updates cache when a component was removed"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponentIndices(); e.RemoveComponentA(); e.GetComponentIndices().should_not_be_same(c); }; it["doesn't update cache when a component was replaced"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponentIndices(); e.ReplaceComponentA(new ComponentA()); e.GetComponentIndices().should_be_same(c); }; it["updates cache when adding a new component with ReplaceComponent"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponentIndices(); e.ReplaceComponentC(Component.C); e.GetComponentIndices().should_not_be_same(c); }; it["updates cache when all components were removed"] = () => { e.AddComponentA(); e.AddComponentB(); var c = e.GetComponentIndices(); e.RemoveAllComponents(); e.GetComponentIndices().should_not_be_same(c); }; }; }; }
void when_entity() { context["when adding ComponentSuffix"] = () => { it["doesn't add component suffix to string ending with ComponentSuffix"] = () => { const string str = "Position" + EntityExtension.COMPONENT_SUFFIX; str.AddComponentSuffix().should_be_same(str); }; it["add ComponentSuffix to string not ending with ComponentSuffix"] = () => { const string str = "Position"; str.AddComponentSuffix().should_be("Position" + EntityExtension.COMPONENT_SUFFIX); }; }; context["when removeing ComponentSuffix"] = () => { it["doesn't change string when not ending with ComponentSuffix"] = () => { const string str = "Position"; str.RemoveComponentSuffix().should_be_same(str); }; it["removes ComponentSuffix when ending with ComponentSuffix"] = () => { const string str = "Position" + EntityExtension.COMPONENT_SUFFIX; str.RemoveComponentSuffix().should_be("Position"); }; }; context["when copying components"] = () => { Pool pool = null; Entity entity = null; Entity target = null; NameAgeComponent nameAge = null; before = () => { pool = new Pool(CID.TotalComponents); entity = pool.CreateEntity(); target = pool.CreateEntity(); nameAge = new NameAgeComponent { name = "Max", age = 42 }; }; it["doesn't change entity if original doesn't have any components"] = () => { entity.CopyTo(target); entity.creationIndex.should_be(0); target.creationIndex.should_be(1); target.GetComponents().Length.should_be(0); }; it["adds copies of all components to target entity"] = () => { entity.AddComponentA(); entity.AddComponent(CID.ComponentB, nameAge); entity.CopyTo(target); target.GetComponents().Length.should_be(2); target.HasComponentA().should_be_true(); target.HasComponentB().should_be_true(); target.GetComponentA().should_not_be_same(Component.A); target.GetComponent(CID.ComponentB).should_not_be_same(nameAge); var clonedComponent = (NameAgeComponent)target.GetComponent(CID.ComponentB); clonedComponent.name.should_be(nameAge.name); clonedComponent.age.should_be(nameAge.age); }; it["throws when target already has a component at index"] = base.expect <EntityAlreadyHasComponentException>(() => { entity.AddComponentA(); entity.AddComponent(CID.ComponentB, nameAge); var component = new NameAgeComponent(); target.AddComponent(CID.ComponentB, component); entity.CopyTo(target); }); it["replaces existing components when overwrite is set"] = () => { entity.AddComponentA(); entity.AddComponent(CID.ComponentB, nameAge); var component = new NameAgeComponent(); target.AddComponent(CID.ComponentB, component); entity.CopyTo(target, true); var copy = target.GetComponent(CID.ComponentB); copy.should_not_be_same(nameAge); copy.should_not_be_same(component); ((NameAgeComponent)copy).name.should_be(nameAge.name); ((NameAgeComponent)copy).age.should_be(nameAge.age); }; it["only adds copies of specified components to target entity"] = () => { entity.AddComponentA(); entity.AddComponentB(); entity.AddComponentC(); entity.CopyTo(target, false, CID.ComponentB, CID.ComponentC); target.GetComponents().Length.should_be(2); target.HasComponentB().should_be_true(); target.HasComponentC().should_be_true(); }; it["uses component pool"] = () => { entity.AddComponentA(); var component = new ComponentA(); target.GetComponentPool(CID.ComponentA).Push(component); entity.CopyTo(target); target.GetComponentA().should_be_same(component); }; }; }