public void RemoveItemFromCollectionTest() { // Arrange _col0.slots[0].SetWithoutValidation(_item, 5); _col0.slots[2].SetWithoutValidation(_item, 5); _col0.slots[4].SetWithoutValidation(_item, 5); _col1.slots[0].SetWithoutValidation(_item, 5); _col1.slots[2].SetWithoutValidation(_item, 5); _col1.slots[4].SetWithoutValidation(_item, 5); // Act var removed = _group.Remove(_item, 12); Assert.IsNull(removed.error); var arr = removed.result.ToArray(); // Assert Assert.IsNull(removed.error); Assert.AreEqual(1, arr.Length); Assert.AreEqual(_col1, arr[0].collection); Assert.IsNull(arr[0].collection[0]); Assert.IsNull(arr[0].collection[2]); Assert.AreEqual(_item, arr[0].collection[4]); Assert.AreEqual(3, arr[0].affectedSlots.Length); Assert.AreEqual(0, arr[0].affectedSlots[0].slot); Assert.AreEqual(2, arr[0].affectedSlots[1].slot); Assert.AreEqual(4, arr[0].affectedSlots[2].slot); Assert.AreEqual(5, arr[0].affectedSlots[0].amount); Assert.AreEqual(5, arr[0].affectedSlots[1].amount); Assert.AreEqual(2, arr[0].affectedSlots[2].amount); Assert.AreEqual(_item, _col0[0]); Assert.AreEqual(5, _col0.GetAmount(0)); Assert.AreEqual(5, _col0.GetAmount(2)); Assert.AreEqual(5, _col0.GetAmount(4)); Assert.AreEqual(_item, _col1[4]); Assert.AreEqual(0, _col1.GetAmount(0)); Assert.AreEqual(0, _col1.GetAmount(2)); Assert.AreEqual(3, _col1.GetAmount(4)); }
public Result <bool> RemoveItem(T item, int amount) { var removed = inventories.Remove(item, amount); if (removed.error != null) { return(new Result <bool>(false, removed.error)); } return(new Result <bool>(true)); }