public void NullRecipeThrowsNullException() { IRecipe recipe = null; //Assert Assert.Throws <NullReferenceException>(() => sut.AddRecipeItem(recipe)); }
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 Throw_Exeption_If_AddRecipeItem_Not_Send_Null() { var inventory = new HeroInventory(); Assert.That( () => inventory.AddRecipeItem(null), Throws.InstanceOf <NullReferenceException>()); }
public void NullRecipeThrowsNullException() { //Arrange var inventory = new HeroInventory(); IRecipe recipe = null; //Assert Assert.Throws <NullReferenceException>(() => inventory.AddRecipeItem(recipe)); }
public void Throll_Exeption_On_Adding_Recipe_With_Same_Name() { var inventory = new HeroInventory(); var itemA = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b" }); var itemB = new RecipeItem("A", 1, 1, 1, 1, 1, new List <string> { "a", "b" }); inventory.AddRecipeItem(itemA); Assert.Throws <ArgumentException>(() => inventory.AddRecipeItem(itemB)); }
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 Chech_If_Recipe_Name_Is_Set_Correct() { var inventory = new HeroInventory(); var itemA = new RecipeItem("A", 1, 2, 3, 4, 5, new List <string>()); inventory.AddRecipeItem(itemA); Assert.AreEqual("A", itemA.Name); }
public void AddRecipe_ShouldNotChangeAgilityBonus() { var inventory = new HeroInventory(); var recipe = new RecipeItem("Oculus", 10, 20, 30, 100, 250, new List <string> { "Staff", "Orb" }); var expected = 0; inventory.AddRecipeItem(recipe); Assert.AreEqual(expected, inventory.TotalAgilityBonus); }
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 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_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 DuplicateRecipeThrowsException() { Assert.Throws <ArgumentException>(() => sut.AddRecipeItem(greatAxeRecipe)); }