public void GroupInvokesOnEntityUpdatedWhenReplacingAComponent() { SetupGroupEntities(); var updated = 0; var prevComp = eA.GetComponent(MyTestComponentsLookup.ComponentA); var newComp = new ComponentA(); var g = _defaultContext.GetGroup(Matcher <MyTestEntity> .AllOf(MyTestComponentsLookup.ComponentA)); g.OnEntityUpdated += (group, entity, index, previousComponent, newComponent) => { updated += 1; Assert.AreEqual(g, group); Assert.AreEqual(eA, entity); Assert.AreEqual(MyTestComponentsLookup.ComponentA, index); Assert.AreEqual(prevComp, previousComponent); Assert.AreEqual(newComp, newComponent); }; eA.ReplaceComponent(MyTestComponentsLookup.ComponentA, newComp); Assert.AreEqual(1, updated); }
public void OnComponentReplacedProvidesBothNewAndPreviousUniqueComponentInstance() { var prevComp = new ComponentA(); var newComp = new ComponentA(); _defaultEntity.OnComponentReplaced += (entity, index, previousComponent, newComponent) => { _didDispatch += 1; Assert.AreEqual(_defaultEntity, entity); Assert.AreEqual(prevComp, previousComponent); Assert.AreEqual(newComp, newComponent); }; _defaultEntity.AddComponent(MyTestComponentsLookup.ComponentA, prevComp); _defaultEntity.ReplaceComponent(MyTestComponentsLookup.ComponentA, newComp); Assert.AreEqual(1, _didDispatch); }