From 09d14d1f330d71bc69a4e9fedace680f9c69de3b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 19 May 2020 20:06:43 +0300 Subject: Did all tests for Service/Tiles/Items and Service/Tiles/Items --- .../Tiles/Crafting/CraftingControllerTests.cs | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs (limited to 'MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs') diff --git a/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs b/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs new file mode 100644 index 0000000..1594f03 --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs @@ -0,0 +1,45 @@ +namespace MundusTests.ServiceTests.Tiles.Crafting +{ + using System.Linq; + using Gtk; + using Mundus.Data; + using Mundus.Data.Tiles.Mobs; + using Mundus.Data.Tiles.Presets; + using Mundus.Data.Windows; + using Mundus.Service.Tiles.Crafting; + using NUnit.Framework; + + [TestFixture] + public static class CraftingControllerTests + { + [OneTimeSetUp] + public static void SetUp() + { + Application.Init(); + DataBaseContexts.CreateInstances(); + WI.CreateInstances(); + WI.WNewGame.OnBtnGenerateClicked(null, null); + } + + [OneTimeTearDown] + public static void TearDown() + { + Application.Quit(); + } + + [Test] + public static void PlayerSuccessfullyCrafts() + { + var recipe = DataBaseContexts.CTContext.CraftingRecipes.First(x => x.ResultItem == "wooden_shovel"); + + for(int i = 0; i < recipe.Count1; i++) + { + MI.Player.Inventory.AppendToItems(MaterialPresets.GetALandStick()); + } + CraftingController.CraftItemPlayer(recipe); + + Assert.Contains(recipe.ResultItem, MI.Player.Inventory.Items.Where(x => x != null).Select(x => x.stock_id).ToArray(), "Result item isn't added to player's inventory"); + Assert.AreEqual(1, MI.Player.Inventory.Items.Where(x => x != null).Count(), "Not all required items are removed from player's inventory"); + } + } +} -- cgit v1.2.3