aboutsummaryrefslogtreecommitdiff
path: root/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs
blob: a399e048bfa6096bacbcde4b6b0414cb813be3d1 (plain) (blame)
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
namespace MundusTests.ServiceTests.Tiles.Items 
{
    using Mundus.Service.Tiles.Items;
    using Mundus.Service.Tiles.Mobs;
    using NUnit.Framework;
    using static Mundus.Service.Tiles.Mobs.Inventory;

    [TestFixture]
    public static class ItemControllerTests 
    {
        [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();
            }
        }
    }
}