aboutsummaryrefslogtreecommitdiff
path: root/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-05-19 20:06:43 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-05-19 20:06:43 +0300
commit09d14d1f330d71bc69a4e9fedace680f9c69de3b (patch)
treed5622e10ef801992945cb5b9d9ea8a9509f465d8 /MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs
parent43e65fb3c92df024ee4eaff454b1fe340c07c41f (diff)
downloadMundus-09d14d1f330d71bc69a4e9fedace680f9c69de3b.tar
Mundus-09d14d1f330d71bc69a4e9fedace680f9c69de3b.tar.gz
Mundus-09d14d1f330d71bc69a4e9fedace680f9c69de3b.zip
Did all tests for Service/Tiles/Items and Service/Tiles/Items
Diffstat (limited to 'MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs')
-rw-r--r--MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs64
1 files changed, 64 insertions, 0 deletions
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();
+ }
+ }
+ }
+}