aboutsummaryrefslogtreecommitdiff
path: root/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs
blob: 9e1e1c6524818711770df4d55d3620bceae13501 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
namespace MundusTests.ServiceTests.SuperLayers 
{
    using Gtk;
    using Mundus.Data;
    using Mundus.Service.SuperLayers;
    using Mundus.Service.Tiles.Mobs;
    using NUnit.Framework;
    using static Mundus.Service.SuperLayers.ImageController;
    using static Mundus.Service.Tiles.Mobs.Inventory;

    [TestFixture]
    public static class ImageControllerTests 
    {
        [Test]
        [TestCase(1, 5)]
        [TestCase(2, 2)]
        [TestCase(8, 10)]
        public static void GetsCorrectGroundImage(int yPos, int xPos) 
        {
            Image img = null;

            if (DataBaseContexts.LContext.GetGroundLayerStock(yPos, xPos) != null) 
            {
                img = new Image(DataBaseContexts.LContext.GetGroundLayerStock(yPos, xPos), IconSize.Dnd);
            }

            if (img == null) 
            {
                Assert.AreEqual(img, ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Ground), $"Ground image at Y:{yPos}, X:{xPos} should be null");
            }
            else 
            {
                Assert.AreEqual(img.Stock, ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Ground).Stock, $"Ground image at Y:{yPos}, X:{xPos} should be {img.Stock}, but is {ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Ground).Stock}");
            }
        }

        [Test]
        [TestCase(1, 5)]
        [TestCase(2, 2)]
        [TestCase(8, 11)]
        public static void GetsCorrectMobImage(int yPos, int xPos) 
        {
            Image img = null;

            if (DataBaseContexts.LContext.GetMobLayerStock(yPos, xPos) != null) 
            {
                img = new Image(DataBaseContexts.LContext.GetMobLayerStock(yPos, xPos), IconSize.Dnd);
            }

            if (img == null) 
            {
                Assert.AreEqual(img, ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Mob), $"Mob image at Y:{yPos}, X:{xPos} should be null");
            }
            else 
            {
                Assert.AreEqual(img.Stock, ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Mob).Stock, $"Mob image at Y:{yPos}, X:{xPos} should be {img.Stock}, but is {ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Ground).Stock}");
            }
        }

        [Test]
        [TestCase(1, 5)]
        [TestCase(2, 2)]
        [TestCase(8, 11)]
        public static void GetsCorrectStructureImage(int yPos, int xPos) 
        {
            Image img = null;

            if (DataBaseContexts.LContext.GetStructureLayerStock(yPos, xPos) != null) 
            {
                img = new Image(DataBaseContexts.LContext.GetStructureLayerStock(yPos, xPos), IconSize.Dnd);
            }

            if (img == null) 
            {
                Assert.AreEqual(img, ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Structure), $"Structure image at Y:{yPos}, X:{xPos} should be null");
            }
            else 
            {
                Assert.AreEqual(img.Stock, ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Structure).Stock, $"Structure image at Y:{yPos}, X:{xPos} should be {img.Stock}, but is {ImageController.GetPlayerScreenImage(yPos, xPos, Layer.Ground).Stock}");
            }
        }

        [Test]
        [TestCase(0)]
        [TestCase(1)]
        [TestCase(2)]
        public static void GetsCorrectPlayerHotbarImage(int index) 
        {
            Image img = new Image("blank", IconSize.Dnd);

            if (MI.Player.Inventory.Hotbar[index] != null) 
            {
                img = new Image(MI.Player.Inventory.Hotbar[index].stock_id, IconSize.Dnd);
            }

            Assert.AreEqual(img.Stock, ImageController.GetPlayerInventoryImage(InventoryPlace.Hotbar, index).Stock, $"Hotbar image at index {index} should be {img.Stock}, but was {ImageController.GetPlayerInventoryImage(InventoryPlace.Hotbar, index).Stock}");
        }

        [Test]
        [TestCase(0)]
        [TestCase(1)]
        [TestCase(2)]
        public static void GetsCorrectPlayerItemsImage(int index) 
        {
            Image img = new Image("blank", IconSize.Dnd);

            if (MI.Player.Inventory.Items[index] != null) 
            {
                img = new Image(MI.Player.Inventory.Items[index].stock_id, IconSize.Dnd);
            }

            Assert.AreEqual(img.Stock, ImageController.GetPlayerInventoryImage(InventoryPlace.Items, index).Stock, $"Items image at index {index} should be {img.Stock}, but was {ImageController.GetPlayerInventoryImage(InventoryPlace.Items, index).Stock}");
        }

        [Test]
        [TestCase(0)]
        [TestCase(1)]
        [TestCase(2)]
        public static void GetsCorrectPlayerAccessoriesImage(int index) 
        {
            Image img = new Image("blank_gear", IconSize.Dnd);

            if (MI.Player.Inventory.Accessories[index] != null) 
            {
                img = new Image(MI.Player.Inventory.Accessories[index].stock_id, IconSize.Dnd);
            }

            Assert.AreEqual(img.Stock, ImageController.GetPlayerInventoryImage(InventoryPlace.Accessories, index).Stock, $"Accessories image at index {index} should be {img.Stock}, but was {ImageController.GetPlayerInventoryImage(InventoryPlace.Accessories, index).Stock}");
        }

        [Test]
        [TestCase(0)]
        [TestCase(1)]
        [TestCase(2)]
        public static void GetsCorrectPlayerGearImage(int index) 
        {
            Image img = new Image("blank_gear", IconSize.Dnd);

            if (MI.Player.Inventory.Gear[index] != null) 
            {
                img = new Image(MI.Player.Inventory.Gear[index].stock_id, IconSize.Dnd);
            }

            Assert.AreEqual(img.Stock, ImageController.GetPlayerInventoryImage(InventoryPlace.Gear, index).Stock, $"Gear image at index {index} should be {img.Stock}, but was {ImageController.GetPlayerInventoryImage(InventoryPlace.Gear, index).Stock}");
        }
    }
}