public void TestUpdate() { GameObject obj = new GameObject(); obj.AddComponent <ContainerLinear>(); ContainerLinear container = obj.GetComponent <ContainerLinear>(); container.Capacity = 5; Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 99))); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 99))); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 99))); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 99))); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 30))); container.UpdateWith(10f); Assert.AreEqual(20.0, container.GetItemStackAt(0).infoTree.ReadDouble("life")); // life decreased container.UpdateWith(30f); Assert.AreEqual(0, container.Count); // properly removed }
public void TestAddGetRemoveStack() { GameObject obj = new GameObject(); obj.AddComponent <ContainerLinear>(); ContainerLinear container = obj.GetComponent <ContainerLinear>(); container.Capacity = 2; Assert.AreEqual(0, container.Count); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 10))); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 10))); Assert.AreEqual(20, container.GetItemStackAt(0).stackSize); Assert.IsNull(container.AddItemStack(new ItemStack(ItemRegistry.ItemDebug, 1))); Assert.AreEqual(ItemRegistry.ItemDebug.id, container.GetItemStackAt(1).itemId); Assert.AreEqual(2, container.Count); Assert.AreEqual(1, container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 80)).stackSize); Assert.AreEqual(20, container.AddItemStack(new ItemStack(ItemRegistry.ItemRadioactive, 20)).stackSize); Assert.AreEqual(99, container.RemoveItemStackAt(0).stackSize); Assert.AreEqual(1, container.Count); }