public void LimitCapacityInFullItemStorageSlot() { var storageSlot = new ItemStorageSlot ( new IInventoryConstraint[] { new WeightedInventoryConstraint(3) } ); var template = new ProceduralItemTemplate() { Weight = 1 }; var itemToAddA = new StackableItem(template, 3); var itemToAddB = new StackableItem(template, 5); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.AreEqual(0, result.Quantity); Assert.AreEqual(InventoryResult.OperationStatus.None, result.Status); Assert.AreEqual(null, result.ItemAdded); }
public void LimitedSlotCapacityForMultipleStackableItems() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 5); var itemToAddB = new StackableItem(template, 10); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.That(result.Status, Is.EqualTo(TransactionStatus.Partial)); Assert.That(result.Items, Has.Count.EqualTo(1)); Assert.That(result.Items[0], Is.EqualTo(new ItemTransaction() { Quantity = 5, Item = itemToAddA, FromInventory = null, ToInventory = storageSlot })); Assert.That(itemToAddB.Quantity, Is.EqualTo(5)); Assert.That(((StackableItem)result.Items[0].Item).Quantity, Is.EqualTo(10)); }
public void LimitCapacityInPartiallyFilledItemStorageSlot() { var storageSlot = new ItemStorageSlot ( new IInventoryConstraint[] { new WeightedInventoryConstraint(3) } ); var template = new ProceduralItemTemplate() { Weight = 1 }; var itemToAddA = new StackableItem(template, 2); var itemToAddB = new StackableItem(template, 2); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); var firstTransaction = result.Items[0]; Assert.AreEqual(3, ((StackableItem)firstTransaction.Item).Quantity); }
public void AllowWeightlessItems() { var storageSlot = new ItemStorageSlot ( constraints: new IInventoryConstraint[] { new WeightedInventoryConstraint(10) } ); var template = new ProceduralItemTemplate() { Weight = 0 }; var itemToAddA = new StackableItem(template, 250) { MaxStackSize = 1000 }; var result = storageSlot.AddItem(itemToAddA); var firstTransaction = result.Items[0]; Assert.AreEqual(250, ((StackableItem)firstTransaction.Item).Quantity); }
public void DragStackableToStackable() { var template = new ProceduralItemTemplate(); var fromItem = new StackableItem(template, 5); var toItem = new StackableItem(template, 10); var fromSlot = new ItemStorageSlot(); var toSlot = new ItemStorageSlot(); fromSlot.AddItem(fromItem); toSlot.AddItem(toItem); var result = fromSlot.DragInto(toSlot); var expected = new InventoryTransactionBuilder() { new ItemTransaction() { FromInventory = fromSlot, ToInventory = toSlot, Item = fromItem, Quantity = 15 } }.Build(TransactionStatus.Complete); // Assert.That (result, Is.EqualTo (expected)); Assert.That(fromItem.Quantity, Is.EqualTo(0)); Assert.That(toItem.Quantity, Is.EqualTo(15)); }
public void CompleteOnFilledFromPartial() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 5); var itemToAddB = new StackableItem(template, 5); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.That(result.Status, Is.EqualTo(TransactionStatus.Complete)); Assert.That(result.Items, Has.Count.EqualTo(1)); Assert.That(result.Items[0], Is.EqualTo(new ItemTransaction() { Quantity = 5, Item = itemToAddA, FromInventory = null, ToInventory = storageSlot })); }
public void CompleteOnFilledFromEmpty() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 10); var result = storageSlot.AddItem(itemToAddA); Assert.AreEqual(10, result.Quantity); Assert.AreEqual(InventoryResult.OperationStatus.Complete, result.Status); Assert.AreEqual(itemToAddA, result.ItemAdded); }
public void NoneOnTryAddToFullStackableSlot() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 10); var itemToAddB = new StackableItem(template, 15); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.AreEqual(TransactionStatus.None, result.Status); }
public void NoneOnTryAddToFullStackableSlot() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 10); var itemToAddB = new StackableItem(template, 15); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.That(result, Is.EqualTo(InventoryTransaction.None)); }
public void MoveStackableToStackableSlot() { var template = new ProceduralItemTemplate(); var fromItem = new StackableItem(template, 5); var toItem = new StackableItem(template, 10); var fromSlot = new ItemStorageSlot(); var toSlot = new ItemStorageSlot(); fromSlot.AddItem(fromItem); toSlot.AddItem(toItem); fromSlot.MoveInto(toSlot); Assert.AreEqual(null, fromSlot.CurrentItem); Assert.AreEqual(toItem, toSlot.CurrentItem); }
public void DragStackableToStackable() { var template = new ProceduralItemTemplate(); var fromItem = new StackableItem(template, 5); var toItem = new StackableItem(template, 10); var fromSlot = new ItemStorageSlot(); var toSlot = new ItemStorageSlot(); fromSlot.AddItem(fromItem); toSlot.AddItem(toItem); fromSlot.DragInto(toSlot); Assert.AreEqual(0, fromItem.Quantity); Assert.AreEqual(15, toItem.Quantity); }
public void SwapUniqueToUnique() { var template = new ProceduralItemTemplate(); var fromItem = new UniqueItem(template); var toItem = new UniqueItem(template); var fromSlot = new ItemStorageSlot(); var toSlot = new ItemStorageSlot(); fromSlot.AddItem(fromItem); toSlot.AddItem(toItem); fromSlot.Swap(toSlot); Assert.AreEqual(toItem, fromSlot.CurrentItem); Assert.AreEqual(fromItem, toSlot.CurrentItem); }
public void LimitedSlotCapacityForMultipleStackableItems() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 5); var itemToAddB = new StackableItem(template, 10); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.AreEqual(5, itemToAddB.Quantity); Assert.AreEqual(10, ((StackableItem)result.ItemAdded).Quantity); }
public void NoneOnTryAddToFullStackableSlot() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 10); var itemToAddB = new StackableItem(template, 15); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); Assert.AreEqual(0, result.Quantity); Assert.AreEqual(InventoryResult.OperationStatus.None, result.Status); Assert.AreEqual(null, result.ItemAdded); }
public void DeclineOverweightedItems() { var storageSlot = new ItemStorageSlot ( new IInventoryConstraint[] { new WeightedInventoryConstraint(10) } ); var template = new ProceduralItemTemplate() { Weight = 100 }; var itemToAdd = new StackableItem(template, 1); var result = storageSlot.AddItem(itemToAdd); Assert.AreEqual(TransactionStatus.None, result.Status); }
public void AllowWeightlessItems() { var storageSlot = new ItemStorageSlot ( new IInventoryConstraint[] { new WeightedInventoryConstraint(10) } ); var template = new ProceduralItemTemplate() { Weight = 0 }; var itemToAddA = new StackableItem(template, 250); var result = storageSlot.AddItem(itemToAddA); Assert.AreEqual(250, ((StackableItem)result.ItemAdded).Quantity); }
public void CompleteOnFilledFromEmpty() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 10); var result = storageSlot.AddItem(itemToAddA); var firstTransaction = result.Items[0]; Assert.AreEqual(TransactionStatus.Complete, result.Status); Assert.AreEqual(10, firstTransaction.Quantity); Assert.AreEqual(itemToAddA, firstTransaction.Item); Assert.AreEqual(null, firstTransaction.FromInventory); Assert.AreEqual(storageSlot, firstTransaction.ToInventory); }
public void LimitCapacityInEmptyFilledItemStorageSlot() { var storageSlot = new ItemStorageSlot ( new IInventoryConstraint[] { new WeightedInventoryConstraint(5) } ); var template = new ProceduralItemTemplate() { Weight = 1 }; var itemToAddA = new StackableItem(template, 10); var result = storageSlot.AddItem(itemToAddA); Assert.AreEqual(5, ((StackableItem)result.ItemAdded).Quantity); }
public void SwapStackableToPartial() { var template = new ProceduralItemTemplate(); var fromItem = new StackableItem(template, 5); var toItem = new StackableItem(template, 10); var fromSlot = new ItemStorageSlot(); var toSlot = new ItemStorageSlot() { MaxStackSize = 15 }; fromSlot.AddItem(fromItem); toSlot.AddItem(toItem); fromSlot.Swap(toSlot); Assert.AreEqual(toItem, fromSlot.CurrentItem); Assert.AreEqual(fromItem, toSlot.CurrentItem); }
public void LimitedSlotCapacityForMultipleStackableItems() { var storageSlot = new ItemStorageSlot() { MaxStackSize = 10 }; var template = new ProceduralItemTemplate(); var itemToAddA = new StackableItem(template, 5); var itemToAddB = new StackableItem(template, 10); storageSlot.AddItem(itemToAddA); var result = storageSlot.AddItem(itemToAddB); var firstTransaction = result.Items[0]; Assert.AreEqual(5, itemToAddB.Quantity); Assert.AreEqual(10, ((StackableItem)firstTransaction.Item).Quantity); Assert.AreEqual(null, firstTransaction.FromInventory); Assert.AreEqual(storageSlot, firstTransaction.ToInventory); }
public void MoveStackableToStackableSlotOverflow() { var template = new ProceduralItemTemplate(); var fromItem = new StackableItem(template, 10); var toItem = new StackableItem(template, 5); var fromSlot = new ItemStorageSlot(); var toSlot = new ItemStorageSlot() { MaxStackSize = 10 }; fromSlot.AddItem(fromItem); toSlot.AddItem(toItem); var result = fromSlot.MoveInto(toSlot); Assert.AreEqual(TransactionStatus.Partial, result.Status); Assert.AreEqual(fromItem, fromSlot.CurrentItem); Assert.AreEqual(toItem, toSlot.CurrentItem); }