public void Chech_Add_Recipe_To_Inventory_Without_Making_Item() { HeroInventory heroInventory = new HeroInventory(); var item1 = new CommonItem("a", 1, 1, 1, 1, 1); var item2 = new CommonItem("b", 1, 1, 1, 1, 1); heroInventory.AddCommonItem(item1); heroInventory.AddCommonItem(item2); var combine = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b", "c" }); heroInventory.AddRecipeItem(combine); Type type = heroInventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(heroInventory); Assert.AreEqual(2, items.Count); var item3 = new CommonItem("c", 1, 1, 1, 1, 1); heroInventory.AddCommonItem(item3); Assert.AreEqual(1, items.Values.Count); }
public void Check_Combine_Method_In_HeroInventory() { var inventory = new HeroInventory(); var item1 = new CommonItem("a", 1, 1, 1, 1, 1); var item2 = new CommonItem("b", 1, 1, 1, 1, 1); var item3 = new CommonItem("c", 1, 1, 1, 1, 1); var item4 = new CommonItem("d", 1, 1, 1, 1, 1); var combine = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b" }); inventory.AddCommonItem(item1); inventory.AddCommonItem(item2); inventory.AddCommonItem(item3); inventory.AddCommonItem(item4); inventory.AddRecipeItem(combine); Type type = inventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(inventory); Assert.AreEqual(3, items.Values.Count); }
public void WhenCommonItemsCall_ShouldReturnAllCommonItems() { IInventory inv = new HeroInventory(); inv.AddCommonItem(new CommonItem("Item1", 1, 2, 4, 4, 5)); inv.AddCommonItem(new CommonItem("Item2", 5, 4, 3, 2, 1)); Assert.That(inv.CommonItems.Count, Is.EqualTo(2)); }
public void WhenAddRecipeItemCall_ShouldCombineCommonItemsInRecipeItem() { IInventory inv = new HeroInventory(); inv.AddCommonItem(new CommonItem("Orb", 1, 2, 4, 4, 5)); inv.AddCommonItem(new CommonItem("Staff", 5, 4, 3, 2, 1)); inv.AddRecipeItem(new RecipeItem("Ring", 10, 10, 10, 10, 10, "Orb", "Staff")); Assert.That(inv.CommonItems.Count, Is.EqualTo(1)); }
public void Totall_Strenth_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 2, 3, 4, 5); var itemB = new CommonItem("B", 6, 7, 8, 9, 0); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(7, inventory.TotalStrengthBonus); }
public void Totall_Damage_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 2, 3, 4, 5); var itemB = new CommonItem("B", 6, 7, 8, 9, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(6, inventory.TotalDamageBonus); }
public void Throll_Exeption_On_Adding_Items_With_Same_Name() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 1, 1, 1); var itemB = new CommonItem("A", 1, 1, 1, 1, 1); inventory.AddCommonItem(itemA); Assert.Throws <ArgumentException>(() => inventory.AddCommonItem(itemB)); }
public void Totall_HitPoints_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 1, 1, 1); var itemB = new CommonItem("B", 1, 1, 1, 1, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(2, inventory.TotalHitPointsBonus); }
public void Totall_Agility_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 13, 2, 1); var itemB = new CommonItem("B", 1, 1, 2, 3, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(2, inventory.TotalAgilityBonus); }
public void Totall_Intelligence_Bonus_Calculate_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 1, 2, 2, 1); var itemB = new CommonItem("B", 1, 1, 13, 13, 1); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); Assert.AreEqual(15, inventory.TotalIntelligenceBonus); }
public void AddTwoItemsAddRecipeCombineRecipe_ShouldCombineRecipe() { var inventory = new HeroInventory(); var item1 = new CommonItem("Staff", 20, 10, 50, 100, 200); var item2 = new CommonItem("Orb", 30, 40, 250, 150, 350); var recipe = new RecipeItem("Oculus", 400, 300, 100, 1000, 2500, new List <string> { "Staff", "Orb" }); var expected = 2500; inventory.AddCommonItem(item1); inventory.AddCommonItem(item2); inventory.AddRecipeItem(recipe); Assert.AreEqual(expected, inventory.TotalDamageBonus); }
public void Check_If_HeroInventory_Add_CommonItem_To_Dictionary() { HeroInventory heroInventory = new HeroInventory(); var item = new CommonItem("maic", 1, 1, 1, 1, 1); var item2 = new CommonItem("mc", 1, 1, 1, 1, 1); Type type = heroInventory.GetType(); FieldInfo[] fieldInfo = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance); FieldInfo commonItemsStorage = fieldInfo.First(f => f.GetCustomAttributes <ItemAttribute>() != null); Dictionary <string, IItem> items = (Dictionary <string, IItem>)commonItemsStorage.GetValue(heroInventory); heroInventory.AddCommonItem(item); heroInventory.AddCommonItem(item2); Assert.AreEqual(2, items.Values.Count); }
public void NullCommonItemThrowsNullException() { CommonItem item = null; //Assert Assert.Throws <NullReferenceException>(() => sut.AddCommonItem(item)); }
public void HeroInventoryAddCommonItemShouldAddItemToItems() { var item = new CommonItem("Pike", 100, 100, 100, 100, 100); heroInventory.AddCommonItem(item); Assert.That(this.commonItems.First().Value, Is.EqualTo(item)); }
public void Throw_Exeption_If_AddCommonItem_Send_Null() { var inventory = new HeroInventory(); Assert.That( () => inventory.AddCommonItem(null), Throws.InstanceOf <NullReferenceException>()); }
public void NullCommonItemThrowsNullException() { //Arrange var inventory = new HeroInventory(); IItem item = null; //Assert Assert.Throws <NullReferenceException>(() => inventory.AddCommonItem(item)); }
public void Check_Reciepe_Item_Crafts_Common_Item_And_Calculate_Damage_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("a", 1, 2, 3, 4, 5); var itemB = new CommonItem("b", 6, 7, 8, 9, 0); var parameters = new List <string> { "a", "b" }; var recItemD = new RecipeItem("c", 20, 30, 40, 50, 60, parameters); inventory.AddCommonItem(itemA); inventory.AddCommonItem(itemB); inventory.AddRecipeItem(recItemD); Assert.AreEqual(60, inventory.TotalDamageBonus); }
public void AddItem_ShouldChangeStrengthBonus() { var inventory = new HeroInventory(); var item1 = new CommonItem("Staff", 20, 10, 50, 100, 2000); var expected = 20; inventory.AddCommonItem(item1); Assert.AreEqual(expected, inventory.TotalStrengthBonus); }
public void Chech_If_Item_Name_Is_Set_Correct() { var inventory = new HeroInventory(); var itemA = new CommonItem("A", 1, 2, 3, 4, 5); inventory.AddCommonItem(itemA); Assert.AreEqual("A", itemA.Name); }
public void TestInit() { sut = new HeroInventory(); axe = new CommonItem("Axe", 1, 2, 3, 1, 2); sword = new CommonItem("Sword", 1, 1, 1, 1, 1); greatAxeRecipe = new RecipeItem("GreatAxe", 5, 5, 6, 4, 4, new List <string>() { "Axe", "Sword" }); sut.AddCommonItem(axe); sut.AddRecipeItem(greatAxeRecipe); }
public void AddItemAddRecipeWithTwoRequiredItems_ShouldNotCombineRecipe() { var inventory = new HeroInventory(); var item1 = new CommonItem("Staff", 20, 10, 50, 200, 300); var recipe = new RecipeItem("Oculus", 400, 500, 600, 1000, 2500, new List <string> { "Staff", "Orb" }); var expected = 200; inventory.AddCommonItem(item1); inventory.AddRecipeItem(recipe); Assert.AreEqual(expected, inventory.TotalHitPointsBonus); }
public void AddsCommonItem() { //Arrange var inventory = new HeroInventory(); IItem item = new CommonItem("Knife", 0, 10, 0, 0, 30); Type getType = inventory.GetType(); var field = getType.GetFields(BindingFlags.Instance | BindingFlags.NonPublic) .FirstOrDefault(f => f.Name.Equals("commonItems", StringComparison.OrdinalIgnoreCase)); var mockField = (Dictionary <string, IItem>)field.GetValue(false); //Assert inventory.AddCommonItem(item); //Assert Assert.AreEqual(1, mockField.Values.Count); }
public void DeletesReqItemsOnObtainingRecipeItems() { sut.AddCommonItem(sword); Assert.IsTrue(sut.TotalStrengthBonus == 5); }