private void CreateUnitsFromInventory() { List <IMyItemInstance> expeditionUnitItems = Inventory.GetItemsWithTag(EXPEDITION_UNIT_ITEM_TAG); foreach (IMyItemInstance item in expeditionUnitItems) { IBoostUnit unit = UnitSpawner.Create(item); ExpeditionUnits.Add(item.GetId(), unit); } }
public void WhenInited_ExpeditionUnitsCreated_ForEachItemWithTag_InPlayersInventory() { IMyItemInstance expeditionUnitItem_1 = CreateExpeditionUnitItemWithId("1"); IMyItemInstance expeditionUnitItem_2 = CreateExpeditionUnitItemWithId("2"); IMyItemInstance expeditionUnitItem_3 = CreateExpeditionUnitItemWithId("3"); List <IMyItemInstance> expeditionUnitItems = new List <IMyItemInstance>() { expeditionUnitItem_1, expeditionUnitItem_2, expeditionUnitItem_3 }; MockInventory.GetItemsWithTag(BoostUnitSaveData.EXPEDITION_UNIT_ITEM_TAG).Returns(expeditionUnitItems); systemUnderTest.Init(); MockUnitSpawner.Received().Create(expeditionUnitItem_1); MockUnitSpawner.Received().Create(expeditionUnitItem_2); MockUnitSpawner.Received().Create(expeditionUnitItem_3); Assert.AreEqual(3, systemUnderTest.ExpeditionUnits.Count); Assert.IsTrue(systemUnderTest.ExpeditionUnits.ContainsKey("1")); Assert.IsTrue(systemUnderTest.ExpeditionUnits.ContainsKey("2")); Assert.IsTrue(systemUnderTest.ExpeditionUnits.ContainsKey("3")); }