public void MaxWeightRestrictionWorks() { WetPaperBag bag = new WetPaperBag(); AddItemStatus actual = bag.AddItem(new GreatAxe()); Assert.AreEqual(AddItemStatus.ContainerOverWeight, actual); }
public void ItemTypeRestriction() { ItemTypeRestriction restriction = new ItemTypeRestriction(ItemType.Weapon); AddItemStatus result = restriction.AddItem(new HealthPotion(), null); Assert.AreEqual(AddItemStatus.ItemWrongType, result); }
public void CanAddItemToBackpack() { Backpack b = new Backpack(); HealthPotion p = new HealthPotion(); AddItemStatus actual = b.AddItem(p); Assert.AreEqual(AddItemStatus.Ok, actual); }
public void CannotAddNonPoitionsToPotionSatchel() { PotionSatchel container = new PotionSatchel(); GreatAxe wrongItemType = new GreatAxe(); AddItemStatus result = container.AddItem(wrongItemType); Assert.AreEqual(result, AddItemStatus.ItemWrongType); }
public AddItemStatus CheckRule(Container addTo, Item toAdd) { AddItemStatus result = AddItemStatus.ItemWrongType; if (toAdd.Type == RestrictionType) { result = AddItemStatus.Ok; } return(result); }
public AddItemStatus CheckRule(Container addTo, Item toAdd) { AddItemStatus result = AddItemStatus.ContainerFull; if (addTo.Capacity > addTo.CurrentIndex) { result = AddItemStatus.Ok; } return(result); }
public void PotionSatchelOnlyAllowsPotions() { PotionSatchel ps = new PotionSatchel(); GreatAxe axe = new GreatAxe(); HealthPotion p = new HealthPotion(); AddItemStatus result = ps.AddItem(axe); Assert.AreEqual(AddItemStatus.ItemNotRightType, result); result = ps.AddItem(p); Assert.AreEqual(AddItemStatus.Success, result); }
public void PotionSatchelOnlyAllowsPotions() { PotionSatchel satchel = new PotionSatchel(); Sword steelsword = new Sword(); AddItemStatus result = satchel.AddItem(steelsword); Assert.AreEqual(AddItemStatus.ItemNotRightType, result); HealthPotion potion = new HealthPotion(); result = satchel.AddItem(potion); Assert.AreEqual(AddItemStatus.Success, result); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); Sword steelSword = new Sword(); b.AddItem(steelSword); b.AddItem(steelSword); b.AddItem(steelSword); b.AddItem(steelSword); AddItemStatus actual = b.AddItem(steelSword); Assert.AreEqual(AddItemStatus.BagIsFull, actual); }
public void PotionSatchelOnlyAllowsPotions() { PotionSatchel satchel = new PotionSatchel(); TurtleArmor armor = new TurtleArmor(); AddItemStatus result = satchel.AddItem(armor); Assert.AreEqual(AddItemStatus.ItemNotRightType, result); HealthPotion potion = new HealthPotion(); result = satchel.AddItem(potion); Assert.AreEqual(AddItemStatus.Success, result); }
public void PotionSatchelOnlyAllowsPotions() { PotionSatchel satchel = new PotionSatchel(); GreatAxe axe = new GreatAxe(); AddItemStatus result = satchel.AddItem(axe); Assert.AreEqual(AddItemStatus.ItemWrongType, result); HealthPotion potion = new HealthPotion(); result = satchel.AddItem(potion); Assert.AreEqual(AddItemStatus.Success, result); }
public override AddItemStatus AddItem(Item itemToAdd) { if (_currentWeight + itemToAdd.Weight > _maxWeight) { return(AddItemStatus.ItemTooHeavy); } AddItemStatus status = base.AddItem(itemToAdd); if (status == AddItemStatus.Success) { _currentWeight += itemToAdd.Weight; } return(status); }
public virtual AddItemStatus AddItem(Item itemToAdd) { foreach (var restriction in _restrictions) { AddItemStatus result = restriction.AddItem(itemToAdd, this); if (result != AddItemStatus.Ok) { return(result); } } Items[CurrentIndex] = itemToAdd; CurrentIndex++; return(AddItemStatus.Ok); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); GreatAxe axe = new GreatAxe(); b.AddItem(axe); b.AddItem(axe); b.AddItem(axe); b.AddItem(axe); AddItemStatus actual = b.AddItem(axe); Assert.AreEqual(AddItemStatus.BagIsFull, actual); }
public void CannotAddItemToFullBackpack() { Backpack p = new Backpack(); GreatAxe g = new GreatAxe(); p.AddItem(g); p.AddItem(g); p.AddItem(g); p.AddItem(g); AddItemStatus actual = p.AddItem(g); Assert.AreEqual(AddItemStatus.ContainerFull, actual); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); TurtleArmor armor = new TurtleArmor(); b.AddItem(armor); b.AddItem(armor); b.AddItem(armor); b.AddItem(armor); AddItemStatus actual = b.AddItem(armor); Assert.AreEqual(AddItemStatus.BagIsFull, actual); }
public AddItemStatus CheckRule(Container addTo, Item toAdd) { var items = addTo.Items.Where(w => w != null); int currentWeight = 0; if (items.Any()) { currentWeight = items.Sum(s => s.Weight); } var proposedWeight = currentWeight + toAdd.Weight; AddItemStatus result = AddItemStatus.ContainerOverweight; if (proposedWeight <= MaxWeight) { result = AddItemStatus.Ok; } return(result); }