1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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();
}
}
}
}
|