aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-05-19 15:06:40 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-05-19 15:06:40 +0300
commit43e65fb3c92df024ee4eaff454b1fe340c07c41f (patch)
tree173ac9708d62d691499f9e633b1beb22f0cca155
parentd580ea82d48831e3cf243e5b250bf7076c8a6b1b (diff)
downloadMundus-43e65fb3c92df024ee4eaff454b1fe340c07c41f.tar
Mundus-43e65fb3c92df024ee4eaff454b1fe340c07c41f.tar.gz
Mundus-43e65fb3c92df024ee4eaff454b1fe340c07c41f.zip
Fixed MITests and did all Service/SuperLayers tests (for HeightController and ImageController)
-rw-r--r--MundusTests/DataTests/Mobs/MITests.cs7
-rw-r--r--MundusTests/MundusTests.csproj3
-rw-r--r--MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs13
-rw-r--r--MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs159
4 files changed, 175 insertions, 7 deletions
diff --git a/MundusTests/DataTests/Mobs/MITests.cs b/MundusTests/DataTests/Mobs/MITests.cs
index 03cc893..b0e33a6 100644
--- a/MundusTests/DataTests/Mobs/MITests.cs
+++ b/MundusTests/DataTests/Mobs/MITests.cs
@@ -9,7 +9,7 @@
[TestFixture]
public static class MITests
{
- [SetUp]
+ [OneTimeSetUp]
public static void SetUp()
{
Application.Init();
@@ -18,6 +18,11 @@
WI.WNewGame.OnBtnGenerateClicked(null, null);
}
+ [OneTimeTearDown]
+ public static void TearDown() {
+ Application.Quit();
+ }
+
[Test]
public static void CreatesPlayerInstance()
{
diff --git a/MundusTests/MundusTests.csproj b/MundusTests/MundusTests.csproj
index e8f95c8..2320858 100644
--- a/MundusTests/MundusTests.csproj
+++ b/MundusTests/MundusTests.csproj
@@ -167,6 +167,7 @@
<Reference Include="MySql.Data.EntityFrameworkCore">
<HintPath>..\packages\MySql.Data.EntityFrameworkCore.8.0.20\lib\netstandard2.0\MySql.Data.EntityFrameworkCore.dll</HintPath>
</Reference>
+ <Reference Include="gdk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" />
</ItemGroup>
<ItemGroup>
<Compile Include="DataTests\GameEventLogs\GameEventLogContextTests.cs" />
@@ -187,6 +188,7 @@
<Compile Include="DataTests\DataBaseContextsTests.cs" />
<Compile Include="ServiceTests\SuperLayers\HeightControllerTests.cs" />
<Compile Include="DataTests\Mobs\MITests.cs" />
+ <Compile Include="ServiceTests\SuperLayers\ImageControllerTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -200,6 +202,7 @@
<Folder Include="ServiceTests\" />
<Folder Include="ServiceTests\SuperLayers\" />
<Folder Include="DataTests\Mobs\" />
+ <Folder Include="ServiceTests\Tiles\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mundus\Mundus.csproj">
diff --git a/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs b/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs
index 0612454..70a2d02 100644
--- a/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs
+++ b/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs
@@ -6,12 +6,15 @@
[TestFixture]
public static class HeightControllerTests
- {
+ {
+ [OneTimeSetUp]
+ public static void SetUp() {
+ DataBaseContexts.CreateInstances();
+ }
+
[Test]
- public static void GetsCorrectSuperLayerUnderneath()
+ public static void GetsCorrectSuperLayerUnderneath()
{
- DataBaseContexts.CreateInstances();
-
Assert.AreEqual(DataBaseContexts.LContext, HeightController.GetSuperLayerUnderneath(DataBaseContexts.SContext), "GetSuperLayerUnderneath doesn't return that land is below sky");
Assert.AreEqual(DataBaseContexts.UContext, HeightController.GetSuperLayerUnderneath(DataBaseContexts.LContext), "GetSuperLayerUnderneath doesn't return that underground is below land");
Assert.AreEqual(null, HeightController.GetSuperLayerUnderneath(DataBaseContexts.UContext), "GetSuperLayerUnderneath doesn't return that there is nothing (null) below underground");
@@ -20,8 +23,6 @@
[Test]
public static void GetsCorrectSuperLayerAbove()
{
- DataBaseContexts.CreateInstances();
-
Assert.AreEqual(null, HeightController.GetSuperLayerAbove(DataBaseContexts.SContext), "GetSuperLayerUnderneath doesn't return that there is nothing (null) above sky");
Assert.AreEqual(DataBaseContexts.SContext, HeightController.GetSuperLayerAbove(DataBaseContexts.LContext), "GetSuperLayerUnderneath doesn't return that sky is above land");
Assert.AreEqual(DataBaseContexts.LContext, HeightController.GetSuperLayerAbove(DataBaseContexts.UContext), "GetSuperLayerUnderneath doesn't return that land is above underground");
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}");
+ }
+ }
+}