public void AddInvalidInputTests() { testObj = new Slot('A', 1, new Candy("ChocolateBar", 2)); testObj.Add(2); testObj.Add(0); Assert.AreEqual(2, testObj.Count, "None were added."); testObj.Add(-2); Assert.AreEqual(2, testObj.Count, "Can't take anything with Add."); }
public void AddTests() { testObj = new Slot('A', 1, new Candy("ChocolateBar", 2)); int excess = testObj.Add(2); Assert.AreEqual(2, testObj.Count, "Just added 2 so there should be 2."); Assert.AreEqual(0, excess, "Should not have had excess added."); excess = testObj.Add(10); Assert.AreEqual(5, testObj.Count, "Just added 10 when there should be a max of 5."); Assert.AreEqual(7, excess, "There should have been excess after adding 10."); }
public void GetItemForSlot(Slot slot) { if (slot.RequiredItemType == typeof(HeadItem)) { slot.Add(CreateHead()); } else if (slot.RequiredItemType == typeof(ArmItem)) { slot.Add(CreateArm()); } else if (slot.RequiredItemType == typeof(LegItem)) { slot.Add(CreateLeg()); } }
public Encounter(int[] slots, EncounterData[] data) : this() { Chances = slots; int i = 0; foreach (int slot in Chances) { Slot.Add(i, new List <Pokemons>()); i++; } Encounters = data; }
public void Add__Slot_with_other_Item_Type__Should_not_add() { var item = this.DefaultItemGenerator(); var otherItem = this.DefaultItemGenerator(); var slot = new Slot(otherItem); var result = slot.Add(item); Assert.IsFalse(result); //Should be false because cannot replace items Assert.AreEqual(otherItem, slot.CurrentItem); //Should keep the currentItem }
public void Add__Should_add_Item_to_empty_Slot() { var item = this.DefaultItemGenerator(); var slot = new Slot(); var result = slot.Add(item); Assert.IsTrue(result); //should IsTrue Assert.IsFalse(slot.isEmpty); //Should not be empty Assert.IsNotNull(slot.CurrentItem); //Should not be null Assert.AreSame(item, slot.CurrentItem); //Should be the item created }
public void Add__Full_Slot_should_not_Add() { var item = new Item( id: Guid.NewGuid().ToString(), name: Guid.NewGuid().ToString(), description: Guid.NewGuid().ToString(), image: null, maxStack: 1 ); var slot = new Slot(item); var result = slot.Add(item); Assert.IsFalse(result); //Should be false because the inventory is full Assert.IsTrue(slot.isFull); //The inventory needs to be full }
public void TakeOneTests() { testObj = new Slot('A', 1, new Candy("ChocolateBar", 2)); Transaction transObj = new Transaction(); Product returnProd = testObj.TakeOne(transObj); Assert.IsNull(returnProd, "User had no money and should not have been given a Product."); transObj.FeedMoney(10); returnProd = testObj.TakeOne(transObj); Assert.IsNull(returnProd, "There is no Products in slot. It should return nothing."); Assert.AreEqual(0, testObj.Count, "Nothing was successfully taken and should therefore be 0."); testObj.Add(2); returnProd = testObj.TakeOne(transObj); Assert.IsNotNull(returnProd, "TakeOne should return the Product when one is successfully taken.."); Assert.AreEqual(1, testObj.Count, "TakeOne should only take 1 from Product."); }
IEnumerator BakeFood() { SetActiveFoodSlots(false); while (items.Count(c => c.cooked) < 2 && !woodsSlot.IsEmpty()) { foreach (Slot slot in slots) { if (slot.IsEmpty()) { break; } if (slot.GetItem().type == Item.Type.FOOD) { FoodItem foodItem = (FoodItem)slot.GetItem(); if (foodItem.cooked) { continue; } foodItem.bakingAmount += bakingSpeed * Time.deltaTime; bakeBar.fillAmount = foodItem.bakingAmount / foodItem.bakingDuration; if (foodItem.bakingAmount >= foodItem.bakingDuration) { foodItem.cooked = true; slot.SetItem(null); } } } yield return(null); } ClearFoodSlots(); mealSlot.SetItem(resultItem, 1); bakeBar.fillAmount = 0f; SetActiveFoodSlots(true); mealSlot.Add(); }
public void Add__Should_stack_Item_to_Slot() { var item = new Item( id: Guid.NewGuid().ToString(), name: Guid.NewGuid().ToString(), description: Guid.NewGuid().ToString(), image: null, maxStack: 2 ); var slot = new Slot(item); var result = slot.Add(item); Assert.IsTrue(result); //Should be true Assert.IsTrue(slot.isFull); //The inventory needs to be full Assert.AreEqual(item, slot.CurrentItem); //Should keep the currentItem }
public void AddAmount__Should_add_the_amount_of_Items() { var amountAndStack = random.Next(1, high_amount); var item = new Item( id: Guid.NewGuid().ToString(), name: Guid.NewGuid().ToString(), description: Guid.NewGuid().ToString(), image: null, maxStack: amountAndStack ); var slot = new Slot(); var result = slot.Add(item, amountAndStack); Assert.AreEqual(0, result); //Should be true Assert.IsTrue(slot.isFull); //Verify if the inventory is full }
public void AddAmount__Should_stack_items() { var amount = random.Next(1, low_amount); var maxStack = amount * 2 + random.Next(0, low_amount / 2); var item = new Item( id: Guid.NewGuid().ToString(), name: Guid.NewGuid().ToString(), description: Guid.NewGuid().ToString(), image: null, maxStack: maxStack ); var slot = new Slot(item, amount); var result = slot.Add(item, amount); Assert.Zero(result); Assert.AreEqual(slot.StackAmount, amount * 2); }
public void AddAmount__Should_return_the_amount_that_coud_not_be_added() { var amount = random.Next(low_amount, high_amount); var maxStack = random.Next(1, low_amount - 1); var item = new Item( id: Guid.NewGuid().ToString(), name: Guid.NewGuid().ToString(), description: Guid.NewGuid().ToString(), image: null, maxStack: maxStack ); var slot = new Slot(); var result = slot.Add(item, amount); Assert.AreEqual(Math.Abs(maxStack - amount), result);//Should be true Assert.IsTrue(slot.isFull); }
public static void Transfer(ref Slot from, ref Slot to, int quantity) { to.Add(from.item, quantity); from.Remove(quantity); }