diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-05-19 20:06:43 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-05-19 20:06:43 +0300 |
| commit | 09d14d1f330d71bc69a4e9fedace680f9c69de3b (patch) | |
| tree | d5622e10ef801992945cb5b9d9ea8a9509f465d8 /MundusTests | |
| parent | 43e65fb3c92df024ee4eaff454b1fe340c07c41f (diff) | |
| download | Mundus-09d14d1f330d71bc69a4e9fedace680f9c69de3b.tar Mundus-09d14d1f330d71bc69a4e9fedace680f9c69de3b.tar.gz Mundus-09d14d1f330d71bc69a4e9fedace680f9c69de3b.zip | |
Did all tests for Service/Tiles/Items and Service/Tiles/Items
Diffstat (limited to 'MundusTests')
8 files changed, 261 insertions, 0 deletions
diff --git a/MundusTests/MundusTests.csproj b/MundusTests/MundusTests.csproj index 2320858..87922b1 100644 --- a/MundusTests/MundusTests.csproj +++ b/MundusTests/MundusTests.csproj @@ -189,6 +189,13 @@ <Compile Include="ServiceTests\SuperLayers\HeightControllerTests.cs" />
<Compile Include="DataTests\Mobs\MITests.cs" />
<Compile Include="ServiceTests\SuperLayers\ImageControllerTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Crafting\CraftingControllerTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Items\Types\GroundTileTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Items\Types\GearTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Items\Types\MaterialTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Items\Types\StructureTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Items\Types\ToolTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Items\ItemControllerTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -203,6 +210,9 @@ <Folder Include="ServiceTests\SuperLayers\" />
<Folder Include="DataTests\Mobs\" />
<Folder Include="ServiceTests\Tiles\" />
+ <Folder Include="ServiceTests\Tiles\Crafting\" />
+ <Folder Include="ServiceTests\Tiles\Items\" />
+ <Folder Include="ServiceTests\Tiles\Items\Types\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mundus\Mundus.csproj">
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"); + } + } +} diff --git a/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs b/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs new file mode 100644 index 0000000..1ccc228 --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs @@ -0,0 +1,64 @@ +using System; +using Mundus.Data; +using NUnit.Framework; +using Gtk; +using Mundus.Data.Windows; +using static Mundus.Service.Tiles.Mobs.Inventory; +using Mundus.Service.Tiles.Items; +using Mundus.Service.Tiles.Mobs; + +namespace MundusTests.ServiceTests.Tiles.Items { + [TestFixture] + public static class ItemControllerTests { + [OneTimeSetUp] + public static void SetUp() { + Application.Init(); + DataBaseContexts.CreateInstances(); + WI.CreateInstances(); + WI.WNewGame.OnBtnGenerateClicked(null, null); + } + + [OneTimeTearDown] + public static void TearDown() { + Application.Quit(); + } + + [Test] + [TestCase(InventoryPlace.Accessories, 1)] + [TestCase(InventoryPlace.Hotbar, 4)] + public static void SelectsItemProperly(InventoryPlace place, int index) { + ItemController.SelectItem(place, index); + + Assert.AreEqual(place, ItemController.SelItemPlace, "Item place isn't set correctly"); + Assert.AreEqual(index, ItemController.SelItemIndex, "Item index isn't set correctly"); + } + + [Test] + [TestCase(InventoryPlace.Hotbar, 1, InventoryPlace.Items, 1)] + public static void SwitchesDifferentItemsProperly(InventoryPlace origin, int originIndex, InventoryPlace destination, int destinationIndex) { + ItemController.SelectItem(destination, destinationIndex); + var destinationItem = Inventory.GetPlayerItemFromItemSelection(); + + ItemController.SelectItem(origin, originIndex); + var originItem = Inventory.GetPlayerItemFromItemSelection(); + + ItemController.SwitchItems(destination, destinationIndex); + + ItemController.SelectItem(origin, originIndex); + if (Inventory.GetPlayerItemFromItemSelection() != null) { + Assert.AreEqual(destinationItem.stock_id, Inventory.GetPlayerItemFromItemSelection().stock_id); + } + else { + Assert.Pass(); + } + + ItemController.SelectItem(destination, destinationIndex); + if (Inventory.GetPlayerItemFromItemSelection() != null) { + Assert.AreEqual(originItem.stock_id, Inventory.GetPlayerItemFromItemSelection()); + } + else { + Assert.Pass(); + } + } + } +} diff --git a/MundusTests/ServiceTests/Tiles/Items/Types/GearTests.cs b/MundusTests/ServiceTests/Tiles/Items/Types/GearTests.cs new file mode 100644 index 0000000..ab3d91c --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Items/Types/GearTests.cs @@ -0,0 +1,28 @@ +namespace MundusTests.ServiceTests.Tiles.Items.Types +{ + using Mundus.Service.Tiles.Items.Types; + using NUnit.Framework; + + [TestFixture] + public static class GearTests + { + [Test] + [TestCase(null)] + [TestCase("test")] + public static void InstantiatesFromStock(string stock_id) + { + Gear gt = new Gear(stock_id); + + Assert.AreEqual(stock_id, gt.stock_id, "Gear doesn't set stock_id properly"); + } + + [Test] + public static void InstantiatesFromAnotherGear() + { + Gear gt = new Gear("testing"); + Gear gt1 = new Gear(gt); + + Assert.AreEqual(gt.stock_id, gt1.stock_id, "Gear constructor doesn't work properly with a groundtile as a parameter"); + } + } +} diff --git a/MundusTests/ServiceTests/Tiles/Items/Types/GroundTileTests.cs b/MundusTests/ServiceTests/Tiles/Items/Types/GroundTileTests.cs new file mode 100644 index 0000000..807d652 --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Items/Types/GroundTileTests.cs @@ -0,0 +1,28 @@ +namespace MundusTests.ServiceTests.Tiles.Items.Types +{ + using Mundus.Service.Tiles.Items.Types; + using NUnit.Framework; + + [TestFixture] + public static class GroundTileTests + { + [Test] + [TestCase(null)] + [TestCase("test")] + public static void InstantiatesFromStock(string stock_id) + { + GroundTile gt = new GroundTile(stock_id, 0); + + Assert.AreEqual(stock_id, gt.stock_id, "GroundTile doesn't set stock_id properly"); + } + + [Test] + public static void InstantiatesFromAnotherGroundTile() + { + GroundTile gt = new GroundTile("testing", 0); + GroundTile gt1 = new GroundTile(gt); + + Assert.AreEqual(gt.stock_id, gt1.stock_id, "GroundTile constructor doesn't work properly with a groundtile as a parameter"); + } + } +} diff --git a/MundusTests/ServiceTests/Tiles/Items/Types/MaterialTests.cs b/MundusTests/ServiceTests/Tiles/Items/Types/MaterialTests.cs new file mode 100644 index 0000000..c4e64d8 --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Items/Types/MaterialTests.cs @@ -0,0 +1,28 @@ +namespace MundusTests.ServiceTests.Tiles.Items.Types +{ + using Mundus.Service.Tiles.Items.Types; + using NUnit.Framework; + + [TestFixture] + public static class MaterialTests + { + [Test] + [TestCase(null)] + [TestCase("test")] + public static void InstantiatesFromStock(string stock_id) + { + Material gt = new Material(stock_id); + + Assert.AreEqual(stock_id, gt.stock_id, "Material doesn't set stock_id properly"); + } + + [Test] + public static void InstantiatesFromAnotherMaterial() + { + Material gt = new Material("testing"); + Material gt1 = new Material(gt); + + Assert.AreEqual(gt.stock_id, gt1.stock_id, "Material constructor doesn't work properly with a groundtile as a parameter"); + } + } +} diff --git a/MundusTests/ServiceTests/Tiles/Items/Types/StructureTests.cs b/MundusTests/ServiceTests/Tiles/Items/Types/StructureTests.cs new file mode 100644 index 0000000..0a18a1b --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Items/Types/StructureTests.cs @@ -0,0 +1,29 @@ +namespace MundusTests.ServiceTests.Tiles.Items.Types +{ + using Mundus.Service.Tiles.Items.Types; + using NUnit.Framework; + using static Mundus.Data.Values; + + [TestFixture] + public static class StructureTests + { + [Test] + [TestCase(null)] + [TestCase("test")] + public static void InstantiatesFromStock(string stock_id) + { + Structure gt = new Structure(stock_id, "", 0, ToolType.Axe, 0); + + Assert.AreEqual(stock_id, gt.stock_id, "Structure doesn't set stock_id properly"); + } + + [Test] + public static void InstantiatesFromAnotherStructure() + { + Structure gt = new Structure("testing", "", 0, ToolType.Axe, 0); + Structure gt1 = new Structure(gt); + + Assert.AreEqual(gt.stock_id, gt1.stock_id, "Structure constructor doesn't work properly with a groundtile as a parameter"); + } + } +} diff --git a/MundusTests/ServiceTests/Tiles/Items/Types/ToolTests.cs b/MundusTests/ServiceTests/Tiles/Items/Types/ToolTests.cs new file mode 100644 index 0000000..79f2438 --- /dev/null +++ b/MundusTests/ServiceTests/Tiles/Items/Types/ToolTests.cs @@ -0,0 +1,29 @@ +namespace MundusTests.ServiceTests.Tiles.Items.Types +{ + using Mundus.Service.Tiles.Items.Types; + using NUnit.Framework; + using static Mundus.Data.Values; + + [TestFixture] + public static class ToolTests + { + [Test] + [TestCase(null)] + [TestCase("test")] + public static void InstantiatesFromStock(string stock_id) + { + Tool gt = new Tool(stock_id, ToolType.Axe, 0); + + Assert.AreEqual(stock_id, gt.stock_id, "Tool doesn't set stock_id properly"); + } + + [Test] + public static void InstantiatesFromAnotherTool() + { + Tool gt = new Tool("testing", ToolType.Axe, 0); + Tool gt1 = new Tool(gt); + + Assert.AreEqual(gt.stock_id, gt1.stock_id, "Tool constructor doesn't work properly with a groundtile as a parameter"); + } + } +} |
