public void DemandTest() { var em = new EntityManager(); var entity = em.CreateEntity(); var producer = CreateWidgetFactory(); entity.AddComponent(producer); var inventory = new Inventory(); inventory.Size = 10; entity.AddComponent(inventory); var productionSystem = new ProductionSystem(_mockEngine); productionSystem.Run(entity); var demand = new Demand(); demand.Demands.Add("widget", 1); entity.AddComponent(demand); var demandSystem = new DemandSystem(_mockEngine); demandSystem.Run(entity); Assert.Less(inventory.Items.Count, 10); }
public void InventoryLimitTest() { var em = new EntityManager(); var entity = em.CreateEntity(); var producer = CreateWidgetFactory(); entity.AddComponent(producer); var inventory = new Inventory(); inventory.Size = 10; entity.AddComponent(inventory); var productionSystem = new ProductionSystem(_mockEngine); productionSystem.Run(entity); Assert.AreEqual(10, inventory.Items.Count); }
public void ProducedItemNameTest() { var em = new EntityManager(); var entity = em.CreateEntity(); var producer = CreateWidgetFactory(); entity.AddComponent(producer); var inventory = new Inventory(); inventory.Size = 10; entity.AddComponent(inventory); var productionSystem = new ProductionSystem(_mockEngine); productionSystem.Run(entity); var item = inventory.Items[0]; var name = item.GetComponent <Item>().Type; Assert.AreEqual(name, producer.ProducedItems[0].product); }