public void OnAddEntity_should_add_entity_and_command_components() { using (var wrappedOp = WorkerOpFactory.CreateAddEntityOp(TestEntityId)) { receiveSystem.OnAddEntity(wrappedOp.Op); } Assert.IsTrue(worker.TryGetEntity(new EntityId(TestEntityId), out var entity)); var id = new SpatialEntityId(); // Default value Assert.DoesNotThrow(() => { id = entityManager.GetComponentData <SpatialEntityId>(entity); }); Assert.AreEqual(TestEntityId, id.EntityId.Id); ComponentType[] worldCommandComponentTypes = { ComponentType.Create <WorldCommands.CreateEntity.CommandSender>(), ComponentType.Create <WorldCommands.DeleteEntity.CommandSender>(), ComponentType.Create <WorldCommands.EntityQuery.CommandSender>(), ComponentType.Create <WorldCommands.ReserveEntityIds.CommandSender>() }; foreach (var type in worldCommandComponentTypes) { Assert.IsTrue(entityManager.HasComponent(entity, type)); } Assert.IsTrue(entityManager.HasComponent(entity, ComponentType.Create <FirstComponentDispatcher.CommandComponent>())); Assert.IsTrue(entityManager.HasComponent(entity, ComponentType.Create <SecondComponentDispatcher.CommandComponent>())); }
public void OnAddEntity_should_throw_if_entity_already_exists() { SetupTestEntity(); using (var wrappedOp = WorkerOpFactory.CreateAddEntityOp(TestEntityId)) { Assert.Throws <InvalidSpatialEntityStateException>(() => { receiveSystem.OnAddEntity(wrappedOp.Op); }); } }