Ejemplo n.º 1
0
        public void CollectionsReadOnlyGroupTest()
        {
            // Arrange
            int addedItemCount    = 0;
            int removedItemCount  = 0;
            int slotsChangedCount = 0;

            _col0.isReadOnly = true;
            _col1.isReadOnly = true;

            _col0.OnAddedItem    += (sender, result) => addedItemCount++;
            _col0.OnRemovedItem  += (sender, result) => removedItemCount++;
            _col0.OnSlotsChanged += (sender, result) => slotsChangedCount++;

            _col1.OnAddedItem    += (sender, result) => addedItemCount++;
            _col1.OnRemovedItem  += (sender, result) => removedItemCount++;
            _col1.OnSlotsChanged += (sender, result) => slotsChangedCount++;

            // Act
            var canAddAmount    = _group.GetCanAddAmount(_item);
            var canAdd          = _group.CanAdd(_item);
            var addResult       = _group.Add(_item);
            var canRemoveResult = _group.CanRemove(_item);
            var removeResult    = _group.Remove(_item);

            // Assert
            Assert.AreEqual(0, addedItemCount);
            Assert.AreEqual(0, removedItemCount);
            Assert.AreEqual(0, slotsChangedCount);

            Assert.AreEqual(Errors.CollectionFull, canAdd.error);
            Assert.AreEqual(Errors.CollectionFull, addResult.error);
            Assert.AreEqual(Errors.CollectionDoesNotContainItem, canRemoveResult.error);
            Assert.AreEqual(Errors.CollectionDoesNotContainItem, removeResult.error);
            Assert.AreEqual(0, canAddAmount);
        }
Ejemplo n.º 2
0
 public Result <bool> CanRemoveItem(T item, int amount = 1)
 {
     return(inventories.CanRemove(item, amount));
 }