diff options
| author | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-05-19 15:06:40 +0300 |
|---|---|---|
| committer | Syndamia <kamen.d.mladenov@protonmail.com> | 2020-05-19 15:06:40 +0300 |
| commit | 43e65fb3c92df024ee4eaff454b1fe340c07c41f (patch) | |
| tree | 173ac9708d62d691499f9e633b1beb22f0cca155 /MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs | |
| parent | d580ea82d48831e3cf243e5b250bf7076c8a6b1b (diff) | |
| download | Mundus-43e65fb3c92df024ee4eaff454b1fe340c07c41f.tar Mundus-43e65fb3c92df024ee4eaff454b1fe340c07c41f.tar.gz Mundus-43e65fb3c92df024ee4eaff454b1fe340c07c41f.zip | |
Fixed MITests and did all Service/SuperLayers tests (for HeightController and ImageController)
Diffstat (limited to 'MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs')
| -rw-r--r-- | MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs b/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs new file mode 100644 index 0000000..c8d8e06 --- /dev/null +++ b/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs @@ -0,0 +1,159 @@ +namespace MundusTests.ServiceTests.SuperLayers +{ + using Gtk; + using Mundus.Data; + using Mundus.Data.Tiles.Mobs; + using Mundus.Data.Windows; + using Mundus.Service.SuperLayers; + using NUnit.Framework; + using static Mundus.Service.SuperLayers.ImageController; + using static Mundus.Service.Tiles.Mobs.Inventory; + + [TestFixture] + public static class ImageControllerTests + { + [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(1, 5)] + [TestCase(2, 2)] + [TestCase(8, 11)] + 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}"); + } + } +} |
