aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSyndamia <kamen.d.mladenov@protonmail.com>2020-05-20 13:12:31 +0300
committerSyndamia <kamen.d.mladenov@protonmail.com>2020-05-20 13:12:31 +0300
commita4e2f6753c6c2612444847fd12f1e973a86a4aa4 (patch)
tree8f97d4ded431e366d8ec5e65172e2f80441dd53f
parent09d14d1f330d71bc69a4e9fedace680f9c69de3b (diff)
downloadMundus-a4e2f6753c6c2612444847fd12f1e973a86a4aa4.tar
Mundus-a4e2f6753c6c2612444847fd12f1e973a86a4aa4.tar.gz
Mundus-a4e2f6753c6c2612444847fd12f1e973a86a4aa4.zip
Fixed test SetUps and TearDowns. Did tests for Inventory and MobTile (Service/Mobs). Did some minor changes to the program.
-rw-r--r--Mundus/Service/GameGenerator.cs22
-rw-r--r--Mundus/Service/Tiles/Mobs/Inventory.cs32
-rw-r--r--Mundus/Views/Windows/NewGameWindow.cs27
-rw-r--r--MundusTests/ApplicationSetup.cs20
-rw-r--r--MundusTests/DataTests/DataBaseContextsTests.cs14
-rw-r--r--MundusTests/DataTests/Mobs/MITests.cs15
-rw-r--r--MundusTests/DataTests/SuperLayers/LandContextTests.cs187
-rw-r--r--MundusTests/DataTests/SuperLayers/SkyContextTests.cs187
-rw-r--r--MundusTests/DataTests/SuperLayers/UndergroundContextTests.cs187
-rw-r--r--MundusTests/MundusTests.csproj4
-rw-r--r--MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs11
-rw-r--r--MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs16
-rw-r--r--MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs15
-rw-r--r--MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs13
-rw-r--r--MundusTests/ServiceTests/Tiles/Mobs/InventoryTests.cs252
-rw-r--r--MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs60
16 files changed, 658 insertions, 404 deletions
diff --git a/Mundus/Service/GameGenerator.cs b/Mundus/Service/GameGenerator.cs
index a2038cd..e5e30b7 100644
--- a/Mundus/Service/GameGenerator.cs
+++ b/Mundus/Service/GameGenerator.cs
@@ -12,15 +12,9 @@
/// Sets the map size and starts generation of all superlayers
/// </summary>
/// <param name="size">Size of the map ("small", "medium" or "large")</param>
- public static void GenerateMap(string size)
+ public static void GenerateMap(Values.MapSize size)
{
- switch (size.ToLower())
- {
- case "small": Values.CurrMapSize = Values.MapSize.SMALL; break;
- case "medium": Values.CurrMapSize = Values.MapSize.MEDIUM; break;
- case "large": Values.CurrMapSize = Values.MapSize.LARGE; break;
- default: throw new ArgumentException("Map size must be \"small\", \"medium\" or \"large\"");
- }
+ Values.CurrMapSize = size;
SkySuperLayerGenerator.GenerateAllLayers(Values.CurrMapSize);
LandSuperLayerGenerator.GenerateAllLayers(Values.CurrMapSize);
@@ -58,17 +52,9 @@
/// Sets the game difficulty (that affects map generation).
/// </summary>
/// <param name="value">Must be "peaceful", "easy", "normal", "hard" or "insane"</param>
- public static void SetDifficulty(string value)
+ public static void SetDifficulty(Values.Difficulty difficulty)
{
- switch (value.ToLower())
- {
- case "peaceful": Values.CurrDifficulty = Values.Difficulty.Peaceful; break;
- case "easy": Values.CurrDifficulty = Values.Difficulty.Easy; break;
- case "normal": Values.CurrDifficulty = Values.Difficulty.Normal; break;
- case "hard": Values.CurrDifficulty = Values.Difficulty.Hard; break;
- case "insane": Values.CurrDifficulty = Values.Difficulty.Insane; break;
- default: throw new ArgumentException($"Invalid difficulty value {value}. Must be \"peaceful\", \"easy\", \"normal\", \"hard\" or \"insane\"");
- }
+ Values.CurrDifficulty = difficulty;
}
}
}
diff --git a/Mundus/Service/Tiles/Mobs/Inventory.cs b/Mundus/Service/Tiles/Mobs/Inventory.cs
index b97a0cc..47b7b91 100644
--- a/Mundus/Service/Tiles/Mobs/Inventory.cs
+++ b/Mundus/Service/Tiles/Mobs/Inventory.cs
@@ -41,14 +41,6 @@
Gear
}
- public void SetSizes(int screenInvSize)
- {
- this.Hotbar = new ItemTile[screenInvSize];
- this.Items = new ItemTile[screenInvSize * screenInvSize];
- this.Accessories = new Gear[screenInvSize * 2];
- this.Gear = new Gear[screenInvSize];
- }
-
public void AppendToHotbar(ItemTile itemTile)
{
this.AddToHotbar(itemTile, Array.IndexOf(this.Hotbar, this.Hotbar.First(x => x == null)));
@@ -79,32 +71,32 @@
this.Items[index] = null;
}
- public void EquipAccessory(Gear accessory, int index)
+ public void AddToAccessories(Gear accessory, int index)
{
this.Accessories[index] = accessory;
}
- public void AppendAccessories(Gear accessory)
+ public void AppendToAccessories(Gear accessory)
{
- this.EquipAccessory(accessory, Array.IndexOf(this.Accessories, this.Accessories.First(x => x == null)));
+ this.AddToAccessories(accessory, Array.IndexOf(this.Accessories, this.Accessories.First(x => x == null)));
}
- public void DeleteAccessory(int index)
+ public void DeleteFromAccessories(int index)
{
this.Accessories[index] = null;
}
- public void EquipGear(Gear gear, int index)
+ public void AddToGear(Gear gear, int index)
{
this.Gear[index] = gear;
}
- public void AppendGear(Gear gear)
+ public void AppendToGear(Gear gear)
{
- this.EquipGear(gear, Array.IndexOf(this.Gear, this.Gear.First(x => x == null)));
+ this.AddToGear(gear, Array.IndexOf(this.Gear, this.Gear.First(x => x == null)));
}
- public void DeleteGear(int index)
+ public void DeleteFromGear(int index)
{
this.Gear[index] = null;
}
@@ -156,5 +148,13 @@
{
return MI.Player.Inventory.GetItemTile(ItemController.SelItemPlace, ItemController.SelItemIndex);
}
+
+ private void SetSizes(int screenInvSize)
+ {
+ this.Hotbar = new ItemTile[screenInvSize];
+ this.Items = new ItemTile[screenInvSize * screenInvSize];
+ this.Accessories = new Gear[screenInvSize * 2];
+ this.Gear = new Gear[screenInvSize];
+ }
}
} \ No newline at end of file
diff --git a/Mundus/Views/Windows/NewGameWindow.cs b/Mundus/Views/Windows/NewGameWindow.cs
index ed4acfb..8a681ca 100644
--- a/Mundus/Views/Windows/NewGameWindow.cs
+++ b/Mundus/Views/Windows/NewGameWindow.cs
@@ -2,6 +2,7 @@
{
using System;
using Gtk;
+ using Mundus.Data;
using Mundus.Service;
using Mundus.Service.Windows;
@@ -74,23 +75,23 @@
}
protected void OnRbPeacefulToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("peaceful");
+ GameGenerator.SetDifficulty(Values.Difficulty.Peaceful);
}
protected void OnRbEasyToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("easy");
+ GameGenerator.SetDifficulty(Values.Difficulty.Easy);
}
protected void OnRbNormalToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("normal");
+ GameGenerator.SetDifficulty(Values.Difficulty.Normal);
}
protected void OnRbHardToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("hard");
+ GameGenerator.SetDifficulty(Values.Difficulty.Hard);
}
protected void OnRbInsaneToggled(object sender, EventArgs e) {
- GameGenerator.SetDifficulty("insane");
+ GameGenerator.SetDifficulty(Values.Difficulty.Insane);
}
/* Automatically set map sizes from screen & inventory size only in survival mode */
@@ -143,23 +144,15 @@
/// </summary>
private void GenerateMap()
{
- string size = null;
+ Values.MapSize size = Values.MapSize.SMALL;
- if (rbMSmall.Active)
+ if (rbMMedium.Active)
{
- size = "small";
- }
- else if (rbMMedium.Active)
- {
- size = "medium";
+ size = Values.MapSize.MEDIUM;
}
else if (rbMLarge.Active)
{
- size = "large";
- }
- else
- {
- throw new ArgumentException("No map size was selected");
+ size = Values.MapSize.LARGE;
}
GameGenerator.GenerateMap(size);
diff --git a/MundusTests/ApplicationSetup.cs b/MundusTests/ApplicationSetup.cs
new file mode 100644
index 0000000..bd39d97
--- /dev/null
+++ b/MundusTests/ApplicationSetup.cs
@@ -0,0 +1,20 @@
+using Mundus.Data;
+using Mundus.Data.Windows;
+using NUnit.Framework;
+using Gtk;
+
+[SetUpFixture]
+public static class ApplicationSetup {
+ [OneTimeSetUp]
+ public static void SetUp() {
+ Application.Init();
+ WI.CreateInstances();
+ DataBaseContexts.CreateInstances();
+ WI.WNewGame.OnBtnGenerateClicked(null, null);
+ }
+
+ [OneTimeTearDown]
+ public static void TearDown() {
+ Application.Quit();
+ }
+}
diff --git a/MundusTests/DataTests/DataBaseContextsTests.cs b/MundusTests/DataTests/DataBaseContextsTests.cs
index e5fcbd1..b4f6f56 100644
--- a/MundusTests/DataTests/DataBaseContextsTests.cs
+++ b/MundusTests/DataTests/DataBaseContextsTests.cs
@@ -7,14 +7,12 @@ namespace MundusTests.DataTests {
public static class DataBaseContextsTests {
[Test]
public static void CreatesInstances() {
- DataBaseContexts.CreateInstances();
-
- Assert.AreNotEqual(null, DataBaseContexts.SContext, "Doesn't create SContext instance");
- Assert.AreNotEqual(null, DataBaseContexts.LContext, "Doesn't create LContext instance");
- Assert.AreNotEqual(null, DataBaseContexts.UContext, "Doesn't create UContext instance");
- Assert.AreNotEqual(null, DataBaseContexts.CTContext, "Doesn't create CTContext instance");
- Assert.AreNotEqual(null, DataBaseContexts.GELContext, "Doesn't create GELContext instance");
- Assert.AreNotEqual(null, DataBaseContexts.SuperLayerContexts, "Doesn't create SuperLayerContexts instance");
+ Assert.IsNotNull(DataBaseContexts.SContext, "Doesn't create SContext instance");
+ Assert.IsNotNull(DataBaseContexts.LContext, "Doesn't create LContext instance");
+ Assert.IsNotNull(DataBaseContexts.UContext, "Doesn't create UContext instance");
+ Assert.IsNotNull(DataBaseContexts.CTContext, "Doesn't create CTContext instance");
+ Assert.IsNotNull(DataBaseContexts.GELContext, "Doesn't create GELContext instance");
+ Assert.IsNotNull(DataBaseContexts.SuperLayerContexts, "Doesn't create SuperLayerContexts instance");
}
}
}
diff --git a/MundusTests/DataTests/Mobs/MITests.cs b/MundusTests/DataTests/Mobs/MITests.cs
index b0e33a6..e37212b 100644
--- a/MundusTests/DataTests/Mobs/MITests.cs
+++ b/MundusTests/DataTests/Mobs/MITests.cs
@@ -9,24 +9,11 @@
[TestFixture]
public static class MITests
{
- [OneTimeSetUp]
- public static void SetUp()
- {
- Application.Init();
- DataBaseContexts.CreateInstances();
- WI.CreateInstances();
- WI.WNewGame.OnBtnGenerateClicked(null, null);
- }
-
- [OneTimeTearDown]
- public static void TearDown() {
- Application.Quit();
- }
[Test]
public static void CreatesPlayerInstance()
{
- Assert.AreNotEqual(null, MI.Player, "Player isn't instantiated");
+ Assert.IsNotNull(MI.Player, "Player isn't instantiated");
}
}
}
diff --git a/MundusTests/DataTests/SuperLayers/LandContextTests.cs b/MundusTests/DataTests/SuperLayers/LandContextTests.cs
index 2329de8..4f4bccb 100644
--- a/MundusTests/DataTests/SuperLayers/LandContextTests.cs
+++ b/MundusTests/DataTests/SuperLayers/LandContextTests.cs
@@ -1,6 +1,7 @@
namespace MundusTests.DataTests.SuperLayers
{
using System.Linq;
+ using Mundus.Data;
using Mundus.Data.SuperLayers;
using Mundus.Data.SuperLayers.DBTables;
using NUnit.Framework;
@@ -11,152 +12,150 @@
[Test]
public static void AddsCorrectValues()
{
- var mob = new LMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 0, 2, 1);
- var ground = new LGPlacedTile("ground_stock", 3, 4);
+ var mob = new LMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new LSPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new LGPlacedTile("ground_stock", 3000, 4000);
- LandContext lc = new LandContext();
+
- lc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- lc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- lc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- lc.SaveChanges();
+ DataBaseContexts.LContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.LContext.SaveChanges();
- Assert.AreEqual(mob.stock_id, lc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't add the mob correctly");
- Assert.AreEqual(structure.stock_id, lc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't add the structure correctly");
- Assert.AreEqual(ground.stock_id, lc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't add the ground correctly");
+ Assert.AreEqual(mob.stock_id, DataBaseContexts.LContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't add the mob correctly");
+ Assert.AreEqual(structure.stock_id, DataBaseContexts.LContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't add the structure correctly");
+ Assert.AreEqual(ground.stock_id, DataBaseContexts.LContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't add the ground correctly");
}
[Test]
public static void ConsideredAliveAfterSmallDamage()
{
- var mob = new LMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new LMPlacedTile("mob_stock", 10, 1000, 1001);
+ var structure = new LSPlacedTile("structure_stock", 4, 2000, 1001);
- LandContext lc = new LandContext();
+
- lc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- lc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- lc.SaveChanges();
+ DataBaseContexts.LContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.SaveChanges();
- Assert.IsTrue(lc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3), "Mob is considered dead (health <= 0), but it shouldnt be");
- Assert.IsTrue(lc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 2), "Structure is considered dead (health <= 0), but it shouldn't be");
+ Assert.IsTrue( DataBaseContexts.LContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 1), "Mob is considered dead (health <= 0), but it shouldnt be");
+ Assert.IsTrue( DataBaseContexts.LContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1), "Structure is considered dead (health <= 0), but it shouldn't be");
}
[Test]
public static void ConsideredDeadAfterBigDamage()
{
- var mob = new LMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new LMPlacedTile("mob_stock", 10, 1000, 1000);
+ var structure = new LSPlacedTile("structure_stock", 4, 2000, 1000);
- LandContext lc = new LandContext();
+
- lc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- lc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- lc.SaveChanges();
+ DataBaseContexts.LContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.SaveChanges();
- Assert.IsFalse(lc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 20), "Mob is considered alive (health > 0), but it shouldnt be");
- Assert.IsFalse(lc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 20), "Structure is considered alive (health > 0), but it shouldn't be");
+ Assert.IsFalse( DataBaseContexts.LContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 20), "Mob is considered alive (health > 0), but it shouldnt be");
+ Assert.IsFalse( DataBaseContexts.LContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 20), "Structure is considered alive (health > 0), but it shouldn't be");
}
[Test]
public static void DamagesCorrectly()
{
- var mob = new LMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new LMPlacedTile("mob_stock", 10, 1000, 1002);
+ var structure = new LSPlacedTile("structure_stock", 4, 2000, 1002);
- LandContext lc = new LandContext();
+ DataBaseContexts.LContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.SaveChanges();
- lc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- lc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- lc.SaveChanges();
+ DataBaseContexts.LContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3);
+ DataBaseContexts.LContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1);
- lc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3);
- lc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1);
-
- Assert.AreEqual(7, lc.LMobLayer.First(x => x.YPos == mob.YPos && x.XPos == mob.XPos).Health, "Mobs recieve incorrect amount of damage");
- Assert.AreEqual(3, lc.LStructureLayer.First(x => x.YPos == structure.YPos && x.XPos == structure.XPos).Health, "Structures recieve incorrect amount of damage");
+ Assert.AreEqual(7, DataBaseContexts.LContext.LMobLayer.First(x => x.YPos == mob.YPos && x.XPos == mob.XPos).Health, "Mobs recieve incorrect amount of damage");
+ Assert.AreEqual(3, DataBaseContexts.LContext.LStructureLayer.First(x => x.YPos == structure.YPos && x.XPos == structure.XPos).Health, "Structures recieve incorrect amount of damage");
}
[Test]
public static void GetsCorrectStocks()
{
- var mob = new LMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 0, 2, 1);
- var ground = new LGPlacedTile("ground_stock", 3, 4);
+ var mob = new LMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new LSPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new LGPlacedTile("ground_stock", 3000, 4000);
- LandContext lc = new LandContext();
+
- lc.LMobLayer.Add(mob);
- lc.LStructureLayer.Add(structure);
- lc.LGroundLayer.Add(ground);
- lc.SaveChanges();
+ DataBaseContexts.LContext.LMobLayer.Add(mob);
+ DataBaseContexts.LContext.LStructureLayer.Add(structure);
+ DataBaseContexts.LContext.LGroundLayer.Add(ground);
+ DataBaseContexts.LContext.SaveChanges();
- Assert.AreEqual(mob.stock_id, lc.GetMobLayerStock(mob.YPos, mob.XPos), "Doesn't get the correct mob layer stock");
- Assert.AreEqual(structure.stock_id, lc.GetStructureLayerStock(structure.YPos,structure.XPos), "Doesn't get the correct structure layer stock");
- Assert.AreEqual(ground.stock_id, lc.GetGroundLayerStock(ground.YPos, ground.XPos), "Doesn't get the correct ground layer stock");
+ Assert.AreEqual(mob.stock_id, DataBaseContexts.LContext.GetMobLayerStock(mob.YPos, mob.XPos), "Doesn't get the correct mob layer stock");
+ Assert.AreEqual(structure.stock_id, DataBaseContexts.LContext.GetStructureLayerStock(structure.YPos,structure.XPos), "Doesn't get the correct structure layer stock");
+ Assert.AreEqual(ground.stock_id, DataBaseContexts.LContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Doesn't get the correct ground layer stock");
}
[Test]
public static void RemovesCorrectValues()
{
- var mob = new LMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 0, 2, 1);
- var ground = new LGPlacedTile("ground_stock", 3, 4);
+ var mob = new LMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new LSPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new LGPlacedTile("ground_stock", 3000, 4000);
- LandContext lc = new LandContext();
+
- lc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- lc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- lc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- lc.SaveChanges();
+ DataBaseContexts.LContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.LContext.SaveChanges();
- lc.RemoveMobFromPosition(mob.YPos, mob.XPos);
- lc.RemoveStructureFromPosition(structure.YPos, structure.XPos);
- lc.RemoveGroundFromPosition(ground.YPos, ground.XPos);
- lc.SaveChanges();
+ DataBaseContexts.LContext.RemoveMobFromPosition(mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.RemoveStructureFromPosition(structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.RemoveGroundFromPosition(ground.YPos, ground.XPos);
+ DataBaseContexts.LContext.SaveChanges();
- Assert.AreEqual(null, lc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't remove the mob correctly");
- Assert.AreEqual(null, lc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't remove the structure correctly");
- Assert.AreEqual(null, lc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't remove the ground correctly");
+ Assert.AreEqual(null, DataBaseContexts.LContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't remove the mob correctly");
+ Assert.AreEqual(null, DataBaseContexts.LContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't remove the structure correctly");
+ Assert.AreEqual(null, DataBaseContexts.LContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't remove the ground correctly");
}
[Test]
public static void SetsCorrectValues()
{
- var mob = new LMPlacedTile("mob_stock", 0, 1, 1);
- var newMob = new LMPlacedTile("new_mob_stock", 1, 1, 1);
- var structure = new LSPlacedTile("structure_stock", 0, 2, 1);
- var newStructure = new LSPlacedTile("new_structure_stock", 1, 2, 1);
- var ground = new LGPlacedTile("ground_stock", 3, 4);
- var newGround = new LGPlacedTile("new_ground_stock", 3, 4);
-
- LandContext lc = new LandContext();
-
- lc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- lc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- lc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- lc.SaveChanges();
-
- lc.SetMobAtPosition(newMob.stock_id, newMob.Health, newMob.YPos, newMob.XPos);
- lc.SetStructureAtPosition(newStructure.stock_id, newStructure.Health, newStructure.YPos, newStructure.XPos);
- lc.SetGroundAtPosition(newGround.stock_id, newGround.YPos, newGround.XPos);
- lc.SaveChanges();
-
- Assert.AreEqual(newMob.stock_id, lc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't set the mob correctly");
- Assert.AreEqual(newStructure.stock_id, lc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't set the structure correctly");
- Assert.AreEqual(newGround.stock_id, lc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't set the ground correctly");
+ var mob = new LMPlacedTile("mob_stock", 0, 1000, 1000);
+ var newMob = new LMPlacedTile("new_mob_stock", 1, 1000, 1000);
+ var structure = new LSPlacedTile("structure_stock", 0, 2000, 1000);
+ var newStructure = new LSPlacedTile("new_structure_stock", 1, 2000, 1000);
+ var ground = new LGPlacedTile("ground_stock", 3000, 4000);
+ var newGround = new LGPlacedTile("new_ground_stock", 3000, 4000);
+
+
+
+ DataBaseContexts.LContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.LContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.LContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.LContext.SaveChanges();
+
+ DataBaseContexts.LContext.SetMobAtPosition(newMob.stock_id, newMob.Health, newMob.YPos, newMob.XPos);
+ DataBaseContexts.LContext.SetStructureAtPosition(newStructure.stock_id, newStructure.Health, newStructure.YPos, newStructure.XPos);
+ DataBaseContexts.LContext.SetGroundAtPosition(newGround.stock_id, newGround.YPos, newGround.XPos);
+ DataBaseContexts.LContext.SaveChanges();
+
+ Assert.AreEqual(newMob.stock_id, DataBaseContexts.LContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't set the mob correctly");
+ Assert.AreEqual(newStructure.stock_id, DataBaseContexts.LContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't set the structure correctly");
+ Assert.AreEqual(newGround.stock_id, DataBaseContexts.LContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't set the ground correctly");
}
- [Test]
- public static void TruncatesTablesOnInitialization()
- {
- LandContext lc = new LandContext();
+ //[Test]
+ //public static void TruncatesTablesOnInitialization()
+ //{
+
- Assert.AreEqual(0, lc.LMobLayer.Count(), "LMobLayer table isn't properly truncated upon LandContext initialization");
- Assert.AreEqual(0, lc.LStructureLayer.Count(), "LStructureLayer table isn't properly truncated upon LandContext initialization");
- Assert.AreEqual(0, lc.LGroundLayer.Count(), "LGroungLayer table isn't properly truncated upon LandContext initialization");
- }
+ // Assert.AreEqual(0, DataBaseContexts.LContext.LMobLayer.Count(), "LMobLayer table isn't properly truncated upon LandContext initialization");
+ // Assert.AreEqual(0, DataBaseContexts.LContext.LStructureLayer.Count(), "LStructureLayer table isn't properly truncated upon LandContext initialization");
+ // Assert.AreEqual(0, DataBaseContexts.LContext.LGroundLayer.Count(), "LGroungLayer table isn't properly truncated upon LandContext initialization");
+ //}
}
}
diff --git a/MundusTests/DataTests/SuperLayers/SkyContextTests.cs b/MundusTests/DataTests/SuperLayers/SkyContextTests.cs
index 9f7f628..ad8771c 100644
--- a/MundusTests/DataTests/SuperLayers/SkyContextTests.cs
+++ b/MundusTests/DataTests/SuperLayers/SkyContextTests.cs
@@ -1,6 +1,7 @@
namespace MundusTests.DataTests.SuperLayers
{
using System.Linq;
+ using Mundus.Data;
using Mundus.Data.SuperLayers;
using Mundus.Data.SuperLayers.DBTables;
using NUnit.Framework;
@@ -11,152 +12,152 @@
[Test]
public static void AddsCorrectValues()
{
- var mob = new SMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 0, 2, 1);
- var ground = new SGPlacedTile("ground_stock", 3, 4);
+ var mob = new SMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new SSPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new SGPlacedTile("ground_stock", 3000, 4000);
- SkyContext sc = new SkyContext();
+
- sc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- sc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- sc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- sc.SaveChanges();
+ DataBaseContexts.SContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.SContext.SaveChanges();
- Assert.AreEqual(mob.stock_id, sc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't add the mob correctly");
- Assert.AreEqual(structure.stock_id, sc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't add the structure correctly");
- Assert.AreEqual(ground.stock_id, sc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't add the ground correctly");
+ Assert.AreEqual(mob.stock_id, DataBaseContexts.SContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't add the mob correctly");
+ Assert.AreEqual(structure.stock_id, DataBaseContexts.SContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't add the structure correctly");
+ Assert.AreEqual(ground.stock_id, DataBaseContexts.SContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't add the ground correctly");
}
[Test]
public static void ConsideredAliveAfterSmallDamage()
{
- var mob = new SMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new SMPlacedTile("mob_stock", 10, 1000, 1001);
+ var structure = new SSPlacedTile("structure_stock", 4, 2000, 1001);
- SkyContext sc = new SkyContext();
+
- sc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- sc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- sc.SaveChanges();
+ DataBaseContexts.SContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.SaveChanges();
- Assert.IsTrue(sc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3), "Mob is considered dead (health <= 0), but it shouldnt be");
- Assert.IsTrue(sc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 2), "Structure is considered dead (health <= 0), but it shouldn't be");
+ Assert.IsTrue( DataBaseContexts.SContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3), "Mob is considered dead (health <= 0), but it shouldnt be");
+ Assert.IsTrue( DataBaseContexts.SContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 2), "Structure is considered dead (health <= 0), but it shouldn't be");
}
[Test]
public static void ConsideredDeadAfterBigDamage()
{
- var mob = new SMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new SMPlacedTile("mob_stock", 10, 1000, 1000);
+ var structure = new SSPlacedTile("structure_stock", 4, 2000, 1000);
- SkyContext sc = new SkyContext();
+
- sc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- sc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- sc.SaveChanges();
+ DataBaseContexts.SContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.SaveChanges();
- Assert.IsFalse(sc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 20), "Mob is considered alive (health > 0), but it shouldnt be");
- Assert.IsFalse(sc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 20), "Structure is considered alive (health > 0), but it shouldn't be");
+ Assert.IsFalse( DataBaseContexts.SContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 20), "Mob is considered alive (health > 0), but it shouldnt be");
+ Assert.IsFalse( DataBaseContexts.SContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 20), "Structure is considered alive (health > 0), but it shouldn't be");
}
[Test]
public static void DamagesCorrectly()
{
- var mob = new SMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new SMPlacedTile("mob_stock", 10, 1000, 1002);
+ var structure = new SSPlacedTile("structure_stock", 4, 2000, 1002);
- SkyContext sc = new SkyContext();
+
- sc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- sc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- sc.SaveChanges();
+ DataBaseContexts.SContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.SaveChanges();
- sc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3);
- sc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1);
+ DataBaseContexts.SContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3);
+ DataBaseContexts.SContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1);
- Assert.AreEqual(7, sc.SMobLayer.First(x => x.YPos == mob.YPos && x.XPos == mob.XPos).Health, "Mobs recieve incorrect amount of damage");
- Assert.AreEqual(3, sc.SStructureLayer.First(x => x.YPos == structure.YPos && x.XPos == structure.XPos).Health, "Structures recieve incorrect amount of damage");
+ Assert.AreEqual(7, DataBaseContexts.SContext.SMobLayer.First(x => x.YPos == mob.YPos && x.XPos == mob.XPos).Health, "Mobs recieve incorrect amount of damage");
+ Assert.AreEqual(3, DataBaseContexts.SContext.SStructureLayer.First(x => x.YPos == structure.YPos && x.XPos == structure.XPos).Health, "Structures recieve incorrect amount of damage");
}
[Test]
public static void GetsCorrectStocks()
{
- var mob = new SMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 0, 2, 1);
- var ground = new SGPlacedTile("ground_stock", 3, 4);
+ var mob = new SMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new SSPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new SGPlacedTile("ground_stock", 3000, 4000);
- SkyContext sc = new SkyContext();
+
- sc.SMobLayer.Add(mob);
- sc.SStructureLayer.Add(structure);
- sc.SGroundLayer.Add(ground);
- sc.SaveChanges();
+ DataBaseContexts.SContext.SMobLayer.Add(mob);
+ DataBaseContexts.SContext.SStructureLayer.Add(structure);
+ DataBaseContexts.SContext.SGroundLayer.Add(ground);
+ DataBaseContexts.SContext.SaveChanges();
- Assert.AreEqual(mob.stock_id, sc.GetMobLayerStock(mob.YPos, mob.XPos), "Doesn't get the correct mob layer stock");
- Assert.AreEqual(structure.stock_id, sc.GetStructureLayerStock(structure.YPos, structure.XPos), "Doesn't get the correct structure layer stock");
- Assert.AreEqual(ground.stock_id, sc.GetGroundLayerStock(ground.YPos, ground.XPos), "Doesn't get the correct ground layer stock");
+ Assert.AreEqual(mob.stock_id, DataBaseContexts.SContext.GetMobLayerStock(mob.YPos, mob.XPos), "Doesn't get the correct mob layer stock");
+ Assert.AreEqual(structure.stock_id, DataBaseContexts.SContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Doesn't get the correct structure layer stock");
+ Assert.AreEqual(ground.stock_id, DataBaseContexts.SContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Doesn't get the correct ground layer stock");
}
[Test]
public static void RemovesCorrectValues()
{
- var mob = new SMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 0, 2, 1);
- var ground = new SGPlacedTile("ground_stock", 3, 4);
+ var mob = new SMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new SSPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new SGPlacedTile("ground_stock", 3000, 4000);
- SkyContext sc = new SkyContext();
+
- sc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- sc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- sc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- sc.SaveChanges();
+ DataBaseContexts.SContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.SContext.SaveChanges();
- sc.RemoveMobFromPosition(mob.YPos, mob.XPos);
- sc.RemoveStructureFromPosition(structure.YPos, structure.XPos);
- sc.RemoveGroundFromPosition(ground.YPos, ground.XPos);
- sc.SaveChanges();
+ DataBaseContexts.SContext.RemoveMobFromPosition(mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.RemoveStructureFromPosition(structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.RemoveGroundFromPosition(ground.YPos, ground.XPos);
+ DataBaseContexts.SContext.SaveChanges();
- Assert.AreEqual(null, sc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't remove the mob correctly");
- Assert.AreEqual(null, sc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't remove the structure correctly");
- Assert.AreEqual(null, sc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't remove the ground correctly");
+ Assert.AreEqual(null, DataBaseContexts.SContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't remove the mob correctly");
+ Assert.AreEqual(null, DataBaseContexts.SContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't remove the structure correctly");
+ Assert.AreEqual(null, DataBaseContexts.SContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't remove the ground correctly");
}
[Test]
public static void SetsCorrectValues()
{
- var mob = new SMPlacedTile("mob_stock", 0, 1, 1);
- var newMob = new SMPlacedTile("new_mob_stock", 1, 1, 1);
- var structure = new SSPlacedTile("structure_stock", 0, 2, 1);
- var newStructure = new SSPlacedTile("new_structure_stock", 1, 2, 1);
- var ground = new SGPlacedTile("ground_stock", 3, 4);
- var newGround = new SGPlacedTile("new_ground_stock", 3, 4);
-
- SkyContext sc = new SkyContext();
-
- sc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- sc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- sc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- sc.SaveChanges();
-
- sc.SetMobAtPosition(newMob.stock_id, newMob.Health, newMob.YPos, newMob.XPos);
- sc.SetStructureAtPosition(newStructure.stock_id, newStructure.Health, newStructure.YPos, newStructure.XPos);
- sc.SetGroundAtPosition(newGround.stock_id, newGround.YPos, newGround.XPos);
- sc.SaveChanges();
-
- Assert.AreEqual(newMob.stock_id, sc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't set the mob correctly");
- Assert.AreEqual(newStructure.stock_id, sc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't set the structure correctly");
- Assert.AreEqual(newGround.stock_id, sc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't set the ground correctly");
+ var mob = new SMPlacedTile("mob_stock", 0, 1000, 1000);
+ var newMob = new SMPlacedTile("new_mob_stock", 1, 1000, 1000);
+ var structure = new SSPlacedTile("structure_stock", 0, 2000, 1000);
+ var newStructure = new SSPlacedTile("new_structure_stock", 1, 2000, 1000);
+ var ground = new SGPlacedTile("ground_stock", 3000, 4000);
+ var newGround = new SGPlacedTile("new_ground_stock", 3000, 4000);
+
+
+
+ DataBaseContexts.SContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.SContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.SContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.SContext.SaveChanges();
+
+ DataBaseContexts.SContext.SetMobAtPosition(newMob.stock_id, newMob.Health, newMob.YPos, newMob.XPos);
+ DataBaseContexts.SContext.SetStructureAtPosition(newStructure.stock_id, newStructure.Health, newStructure.YPos, newStructure.XPos);
+ DataBaseContexts.SContext.SetGroundAtPosition(newGround.stock_id, newGround.YPos, newGround.XPos);
+ DataBaseContexts.SContext.SaveChanges();
+
+ Assert.AreEqual(newMob.stock_id, DataBaseContexts.SContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't set the mob correctly");
+ Assert.AreEqual(newStructure.stock_id, DataBaseContexts.SContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't set the structure correctly");
+ Assert.AreEqual(newGround.stock_id, DataBaseContexts.SContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't set the ground correctly");
}
- [Test]
- public static void TruncatesTablesOnInitialization()
- {
- SkyContext sc = new SkyContext();
+ //[Test]
+ //public static void TruncatesTablesOnInitialization()
+ //{
+
- Assert.AreEqual(0, sc.SMobLayer.Count(), "SMobLayer table isn't properly truncated upon SkyContext initialization");
- Assert.AreEqual(0, sc.SStructureLayer.Count(), "SStructureLayer table isn't properly truncated upon SkyContext initialization");
- Assert.AreEqual(0, sc.SGroundLayer.Count(), "LGroungLayer table isn't properly truncated upon SkyContext initialization");
- }
+ // Assert.AreEqual(0, DataBaseContexts.SContext.SMobLayer.Count(), "SMobLayer table isn't properly truncated upon SkyContext initialization");
+ // Assert.AreEqual(0, DataBaseContexts.SContext.SStructureLayer.Count(), "SStructureLayer table isn't properly truncated upon SkyContext initialization");
+ // Assert.AreEqual(0, DataBaseContexts.SContext.SGroundLayer.Count(), "LGroungLayer table isn't properly truncated upon SkyContext initialization");
+ //}
}
}
diff --git a/MundusTests/DataTests/SuperLayers/UndergroundContextTests.cs b/MundusTests/DataTests/SuperLayers/UndergroundContextTests.cs
index 6cb46af..0cf938f 100644
--- a/MundusTests/DataTests/SuperLayers/UndergroundContextTests.cs
+++ b/MundusTests/DataTests/SuperLayers/UndergroundContextTests.cs
@@ -1,6 +1,7 @@
namespace MundusTests.DataTests.SuperLayers
{
using System.Linq;
+ using Mundus.Data;
using Mundus.Data.SuperLayers;
using Mundus.Data.SuperLayers.DBTables;
using NUnit.Framework;
@@ -11,152 +12,152 @@
[Test]
public static void AddsCorrectValues()
{
- var mob = new UMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new USPlacedTile("structure_stock", 0, 2, 1);
- var ground = new UGPlacedTile("ground_stock", 3, 4);
+ var mob = new UMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new USPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new UGPlacedTile("ground_stock", 3000, 4000);
- UndergroundContext uc = new UndergroundContext();
+
- uc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- uc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- uc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- uc.SaveChanges();
+ DataBaseContexts.UContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.UContext.SaveChanges();
- Assert.AreEqual(mob.stock_id, uc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't add the mob correctly");
- Assert.AreEqual(structure.stock_id, uc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't add the structure correctly");
- Assert.AreEqual(ground.stock_id, uc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't add the ground correctly");
+ Assert.AreEqual(mob.stock_id, DataBaseContexts.UContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't add the mob correctly");
+ Assert.AreEqual(structure.stock_id, DataBaseContexts.UContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't add the structure correctly");
+ Assert.AreEqual(ground.stock_id, DataBaseContexts.UContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't add the ground correctly");
}
[Test]
public static void ConsideredAliveAfterSmallDamage()
{
- var mob = new UMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new USPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new UMPlacedTile("mob_stock", 10, 1000, 1001);
+ var structure = new USPlacedTile("structure_stock", 4, 2000, 1001);
- UndergroundContext uc = new UndergroundContext();
+
- uc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- uc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- uc.SaveChanges();
+ DataBaseContexts.UContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.SaveChanges();
- Assert.IsTrue(uc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3), "Mob is considered dead (health <= 0), but it shouldnt be");
- Assert.IsTrue(uc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 2), "Structure is considered dead (health <= 0), but it shouldn't be");
+ Assert.IsTrue( DataBaseContexts.UContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3), "Mob is considered dead (health <= 0), but it shouldnt be");
+ Assert.IsTrue( DataBaseContexts.UContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 2), "Structure is considered dead (health <= 0), but it shouldn't be");
}
[Test]
public static void ConsideredDeadAfterBigDamage()
{
- var mob = new UMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new USPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new UMPlacedTile("mob_stock", 10, 1000, 1000);
+ var structure = new USPlacedTile("structure_stock", 4, 2000, 1000);
- UndergroundContext uc = new UndergroundContext();
+
- uc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- uc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- uc.SaveChanges();
+ DataBaseContexts.UContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.SaveChanges();
- Assert.IsFalse(uc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 20), "Mob is considered alive (health > 0), but it shouldnt be");
- Assert.IsFalse(uc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 20), "Structure is considered alive (health > 0), but it shouldn't be");
+ Assert.IsFalse( DataBaseContexts.UContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 20), "Mob is considered alive (health > 0), but it shouldnt be");
+ Assert.IsFalse( DataBaseContexts.UContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 20), "Structure is considered alive (health > 0), but it shouldn't be");
}
[Test]
public static void DamagesCorrectly()
{
- var mob = new UMPlacedTile("mob_stock", 10, 1, 1);
- var structure = new USPlacedTile("structure_stock", 4, 2, 1);
+ var mob = new UMPlacedTile("mob_stock", 10, 1000, 1002);
+ var structure = new USPlacedTile("structure_stock", 4, 2000, 1002);
- UndergroundContext uc = new UndergroundContext();
+
- uc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- uc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- uc.SaveChanges();
+ DataBaseContexts.UContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.SaveChanges();
- uc.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3);
- uc.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1);
+ DataBaseContexts.UContext.TakeDamageMobAtPosition(mob.YPos, mob.XPos, 3);
+ DataBaseContexts.UContext.TakeDamageStructureAtPosition(structure.YPos, structure.XPos, 1);
- Assert.AreEqual(7, uc.UMobLayer.First(x => x.YPos == mob.YPos && x.XPos == mob.XPos).Health, "Mobs recieve incorrect amount of damage");
- Assert.AreEqual(3, uc.UStructureLayer.First(x => x.YPos == structure.YPos && x.XPos == structure.XPos).Health, "Structures recieve incorrect amount of damage");
+ Assert.AreEqual(7, DataBaseContexts.UContext.UMobLayer.First(x => x.YPos == mob.YPos && x.XPos == mob.XPos).Health, "Mobs recieve incorrect amount of damage");
+ Assert.AreEqual(3, DataBaseContexts.UContext.UStructureLayer.First(x => x.YPos == structure.YPos && x.XPos == structure.XPos).Health, "Structures recieve incorrect amount of damage");
}
[Test]
public static void GetsCorrectStocks()
{
- var mob = new UMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new USPlacedTile("structure_stock", 0, 2, 1);
- var ground = new UGPlacedTile("ground_stock", 3, 4);
+ var mob = new UMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new USPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new UGPlacedTile("ground_stock", 3000, 4000);
- UndergroundContext uc = new UndergroundContext();
+
- uc.UMobLayer.Add(mob);
- uc.UStructureLayer.Add(structure);
- uc.UGroundLayer.Add(ground);
- uc.SaveChanges();
+ DataBaseContexts.UContext.UMobLayer.Add(mob);
+ DataBaseContexts.UContext.UStructureLayer.Add(structure);
+ DataBaseContexts.UContext.UGroundLayer.Add(ground);
+ DataBaseContexts.UContext.SaveChanges();
- Assert.AreEqual(mob.stock_id, uc.GetMobLayerStock(mob.YPos, mob.XPos), "Doesn't get the correct mob layer stock");
- Assert.AreEqual(structure.stock_id, uc.GetStructureLayerStock(structure.YPos, structure.XPos), "Doesn't get the correct structure layer stock");
- Assert.AreEqual(ground.stock_id, uc.GetGroundLayerStock(ground.YPos, ground.XPos), "Doesn't get the correct ground layer stock");
+ Assert.AreEqual(mob.stock_id, DataBaseContexts.UContext.GetMobLayerStock(mob.YPos, mob.XPos), "Doesn't get the correct mob layer stock");
+ Assert.AreEqual(structure.stock_id, DataBaseContexts.UContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Doesn't get the correct structure layer stock");
+ Assert.AreEqual(ground.stock_id, DataBaseContexts.UContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Doesn't get the correct ground layer stock");
}
[Test]
public static void RemovesCorrectValues()
{
- var mob = new UMPlacedTile("mob_stock", 0, 1, 1);
- var structure = new USPlacedTile("structure_stock", 0, 2, 1);
- var ground = new UGPlacedTile("ground_stock", 3, 4);
+ var mob = new UMPlacedTile("mob_stock", 0, 1000, 1000);
+ var structure = new USPlacedTile("structure_stock", 0, 2000, 1000);
+ var ground = new UGPlacedTile("ground_stock", 3000, 4000);
- UndergroundContext uc = new UndergroundContext();
+
- uc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- uc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- uc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- uc.SaveChanges();
+ DataBaseContexts.UContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.UContext.SaveChanges();
- uc.RemoveMobFromPosition(mob.YPos, mob.XPos);
- uc.RemoveStructureFromPosition(structure.YPos, structure.XPos);
- uc.RemoveGroundFromPosition(ground.YPos, ground.XPos);
- uc.SaveChanges();
+ DataBaseContexts.UContext.RemoveMobFromPosition(mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.RemoveStructureFromPosition(structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.RemoveGroundFromPosition(ground.YPos, ground.XPos);
+ DataBaseContexts.UContext.SaveChanges();
- Assert.AreEqual(null, uc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't remove the mob correctly");
- Assert.AreEqual(null, uc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't remove the structure correctly");
- Assert.AreEqual(null, uc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't remove the ground correctly");
+ Assert.AreEqual(null, DataBaseContexts.UContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't remove the mob correctly");
+ Assert.AreEqual(null, DataBaseContexts.UContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't remove the structure correctly");
+ Assert.AreEqual(null, DataBaseContexts.UContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't remove the ground correctly");
}
[Test]
public static void SetsCorrectValues()
{
- var mob = new UMPlacedTile("mob_stock", 0, 1, 1);
- var newMob = new UMPlacedTile("new_mob_stock", 1, 1, 1);
- var structure = new USPlacedTile("structure_stock", 0, 2, 1);
- var newStructure = new USPlacedTile("new_structure_stock", 1, 2, 1);
- var ground = new UGPlacedTile("ground_stock", 3, 4);
- var newGround = new UGPlacedTile("new_ground_stock", 3, 4);
-
- UndergroundContext uc = new UndergroundContext();
-
- uc.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
- uc.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
- uc.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
- uc.SaveChanges();
-
- uc.SetMobAtPosition(newMob.stock_id, newMob.Health, newMob.YPos, newMob.XPos);
- uc.SetStructureAtPosition(newStructure.stock_id, newStructure.Health, newStructure.YPos, newStructure.XPos);
- uc.SetGroundAtPosition(newGround.stock_id, newGround.YPos, newGround.XPos);
- uc.SaveChanges();
-
- Assert.AreEqual(newMob.stock_id, uc.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't set the mob correctly");
- Assert.AreEqual(newStructure.stock_id, uc.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't set the structure correctly");
- Assert.AreEqual(newGround.stock_id, uc.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't set the ground correctly");
+ var mob = new UMPlacedTile("mob_stock", 0, 1000, 1000);
+ var newMob = new UMPlacedTile("new_mob_stock", 1, 1000, 1000);
+ var structure = new USPlacedTile("structure_stock", 0, 2000, 1000);
+ var newStructure = new USPlacedTile("new_structure_stock", 1, 2000, 1000);
+ var ground = new UGPlacedTile("ground_stock", 3000, 4000);
+ var newGround = new UGPlacedTile("new_ground_stock", 3000, 4000);
+
+
+
+ DataBaseContexts.UContext.AddMobAtPosition(mob.stock_id, mob.Health, mob.YPos, mob.XPos);
+ DataBaseContexts.UContext.AddStructureAtPosition(structure.stock_id, structure.Health, structure.YPos, structure.XPos);
+ DataBaseContexts.UContext.AddGroundAtPosition(ground.stock_id, ground.YPos, ground.XPos);
+ DataBaseContexts.UContext.SaveChanges();
+
+ DataBaseContexts.UContext.SetMobAtPosition(newMob.stock_id, newMob.Health, newMob.YPos, newMob.XPos);
+ DataBaseContexts.UContext.SetStructureAtPosition(newStructure.stock_id, newStructure.Health, newStructure.YPos, newStructure.XPos);
+ DataBaseContexts.UContext.SetGroundAtPosition(newGround.stock_id, newGround.YPos, newGround.XPos);
+ DataBaseContexts.UContext.SaveChanges();
+
+ Assert.AreEqual(newMob.stock_id, DataBaseContexts.UContext.GetMobLayerStock(mob.YPos, mob.XPos), "Didn't set the mob correctly");
+ Assert.AreEqual(newStructure.stock_id, DataBaseContexts.UContext.GetStructureLayerStock(structure.YPos, structure.XPos), "Didn't set the structure correctly");
+ Assert.AreEqual(newGround.stock_id, DataBaseContexts.UContext.GetGroundLayerStock(ground.YPos, ground.XPos), "Didn't set the ground correctly");
}
- [Test]
- public static void TruncatesTablesOnInitialization()
- {
- UndergroundContext uc = new UndergroundContext();
+ //[Test]
+ //public static void TruncatesTablesOnInitialization()
+ //{
+
- Assert.AreEqual(0, uc.UMobLayer.Count(), "UMobLayer table isn't properly truncated upon UndergroundContext initialization");
- Assert.AreEqual(0, uc.UStructureLayer.Count(), "UStructureLayer table isn't properly truncated upon UndergroundContext initialization");
- Assert.AreEqual(0, uc.UGroundLayer.Count(), "LGroungLayer table isn't properly truncated upon UndergroundContext initialization");
- }
+ // Assert.AreEqual(0, DataBaseContexts.UContext.UMobLayer.Count(), "UMobLayer table isn't properly truncated upon UndergroundContext initialization");
+ // Assert.AreEqual(0, DataBaseContexts.UContext.UStructureLayer.Count(), "UStructureLayer table isn't properly truncated upon UndergroundContext initialization");
+ // Assert.AreEqual(0, DataBaseContexts.UContext.UGroundLayer.Count(), "LGroungLayer table isn't properly truncated upon UndergroundContext initialization");
+ //}
}
}
diff --git a/MundusTests/MundusTests.csproj b/MundusTests/MundusTests.csproj
index 87922b1..bb185b7 100644
--- a/MundusTests/MundusTests.csproj
+++ b/MundusTests/MundusTests.csproj
@@ -196,6 +196,9 @@
<Compile Include="ServiceTests\Tiles\Items\Types\StructureTests.cs" />
<Compile Include="ServiceTests\Tiles\Items\Types\ToolTests.cs" />
<Compile Include="ServiceTests\Tiles\Items\ItemControllerTests.cs" />
+ <Compile Include="ServiceTests\Tiles\Mobs\InventoryTests.cs" />
+ <Compile Include="ApplicationSetup.cs" />
+ <Compile Include="ServiceTests\Tiles\Mobs\MobTileTests.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
@@ -213,6 +216,7 @@
<Folder Include="ServiceTests\Tiles\Crafting\" />
<Folder Include="ServiceTests\Tiles\Items\" />
<Folder Include="ServiceTests\Tiles\Items\Types\" />
+ <Folder Include="ServiceTests\Tiles\Mobs\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Mundus\Mundus.csproj">
diff --git a/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs b/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs
index 70a2d02..88aa4aa 100644
--- a/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs
+++ b/MundusTests/ServiceTests/SuperLayers/HeightControllerTests.cs
@@ -6,24 +6,19 @@
[TestFixture]
public static class HeightControllerTests
- {
- [OneTimeSetUp]
- public static void SetUp() {
- DataBaseContexts.CreateInstances();
- }
-
+ {
[Test]
public static void GetsCorrectSuperLayerUnderneath()
{
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");
+ Assert.IsNull(HeightController.GetSuperLayerUnderneath(DataBaseContexts.UContext), "GetSuperLayerUnderneath doesn't return that there is nothing (null) below underground");
}
[Test]
public static void GetsCorrectSuperLayerAbove()
{
- Assert.AreEqual(null, HeightController.GetSuperLayerAbove(DataBaseContexts.SContext), "GetSuperLayerUnderneath doesn't return that there is nothing (null) above sky");
+ Assert.IsNull(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
index c8d8e06..9ab6418 100644
--- a/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs
+++ b/MundusTests/ServiceTests/SuperLayers/ImageControllerTests.cs
@@ -12,25 +12,11 @@
[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)]
+ [TestCase(8, 10)]
public static void GetsCorrectGroundImage(int yPos, int xPos)
{
Image img = null;
diff --git a/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs b/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs
index 1594f03..e0cd66d 100644
--- a/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs
+++ b/MundusTests/ServiceTests/Tiles/Crafting/CraftingControllerTests.cs
@@ -12,21 +12,6 @@
[TestFixture]
public static class CraftingControllerTests
{
- [OneTimeSetUp]
- public static void SetUp()
- {
- Application.Init();
- DataBaseContexts.CreateInstances();
- WI.CreateInstances();
- WI.WNewGame.OnBtnGenerateClicked(null, null);
- }
-
- [OneTimeTearDown]
- public static void TearDown()
- {
- Application.Quit();
- }
-
[Test]
public static void PlayerSuccessfullyCrafts()
{
diff --git a/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs b/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs
index 1ccc228..497ccf3 100644
--- a/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs
+++ b/MundusTests/ServiceTests/Tiles/Items/ItemControllerTests.cs
@@ -10,19 +10,6 @@ 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)]
diff --git a/MundusTests/ServiceTests/Tiles/Mobs/InventoryTests.cs b/MundusTests/ServiceTests/Tiles/Mobs/InventoryTests.cs
new file mode 100644
index 0000000..9f0d687
--- /dev/null
+++ b/MundusTests/ServiceTests/Tiles/Mobs/InventoryTests.cs
@@ -0,0 +1,252 @@
+using System;
+using Mundus.Service.Tiles.Items;
+using Mundus.Service.Tiles.Items.Types;
+using Mundus.Service.Tiles.Mobs;
+using NUnit.Framework;
+
+namespace MundusTests.ServiceTests.Tiles.Mobs {
+ [TestFixture]
+ public static class InventoryTests {
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AddsToHotbar(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToHotbar(new Material(stock_id1), 2);
+ inv.AddToHotbar(new Material(stock_id2), 4);
+
+ Assert.AreEqual(stock_id1, inv.Hotbar[2].stock_id, "Add to hotbar doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Hotbar[4].stock_id, "Add to hotbar doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AddsToItems(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToItems(new Material(stock_id1), 2);
+ inv.AddToItems(new Material(stock_id2), 4);
+
+ Assert.AreEqual(stock_id1, inv.Items[2].stock_id, "Add to items doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Items[4].stock_id, "Add to items doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AddsToAccessories(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToAccessories(new Gear(stock_id1), 2);
+ inv.AddToAccessories(new Gear(stock_id2), 4);
+
+ Assert.AreEqual(stock_id1, inv.Accessories[2].stock_id, "Add to accessories doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Accessories[4].stock_id, "Add to accessories doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AddsToGear(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToGear(new Gear(stock_id1), 2);
+ inv.AddToGear(new Gear(stock_id2), 4);
+
+ Assert.AreEqual(stock_id1, inv.Gear[2].stock_id, "Add to gear doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Gear[4].stock_id, "Add to gear doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AppendsToHotbar(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AppendToHotbar(new Material(stock_id1));
+ inv.AppendToHotbar(new Material(stock_id2));
+
+ Assert.AreEqual(stock_id1, inv.Hotbar[0].stock_id, "Append to hotbar doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Hotbar[1].stock_id, "Append to hotbar doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AppendsToItems(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AppendToItems(new Material(stock_id1));
+ inv.AppendToItems(new Material(stock_id2));
+
+ Assert.AreEqual(stock_id1, inv.Items[0].stock_id, "Append to items doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Items[1].stock_id, "Append to items doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AppendsToAccessories(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AppendToAccessories(new Gear(stock_id1));
+ inv.AppendToAccessories(new Gear(stock_id2));
+
+ Assert.AreEqual(stock_id1, inv.Accessories[0].stock_id, "Append to accessories doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Accessories[1].stock_id, "Append to accessories doesn't work as expected");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void AppendsToGear(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AppendToGear(new Gear(stock_id1));
+ inv.AppendToGear(new Gear(stock_id2));
+
+ Assert.AreEqual(stock_id1, inv.Gear[0].stock_id, "Append to gear doesn't work as expected");
+ Assert.AreEqual(stock_id2, inv.Gear[1].stock_id, "Append to gear doesn't work as expected");
+ }
+
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void DeletesFromHotbar(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToHotbar(new Gear(stock_id1), 2);
+ inv.AddToHotbar(new Gear(stock_id2), 4);
+
+ inv.DeleteFromHotbar(2);
+ inv.DeleteFromHotbar(4);
+
+ Assert.IsNull(inv.Hotbar[2], "Doesn't delete item properly from hotbar");
+ Assert.IsNull(inv.Hotbar[4], "Doesn't delete item properly from hotbar");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void DeletesFromItems(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToItems(new Gear(stock_id1), 2);
+ inv.AddToItems(new Gear(stock_id2), 4);
+
+ inv.DeleteFromItems(2);
+ inv.DeleteFromItems(4);
+
+ Assert.IsNull(inv.Items[2], "Doesn't delete item properly from items");
+ Assert.IsNull(inv.Items[4], "Doesn't delete item properly from items");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void DeletesFromAccessories(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToAccessories(new Gear(stock_id1), 2);
+ inv.AddToAccessories(new Gear(stock_id2), 4);
+
+ inv.DeleteFromAccessories(2);
+ inv.DeleteFromAccessories(4);
+
+ Assert.IsNull(inv.Accessories[2], "Doesn't delete item properly from accessories");
+ Assert.IsNull(inv.Accessories[4], "Doesn't delete item properly from accessories");
+ }
+
+ [Test]
+ [TestCase("one", "two")]
+ [TestCase(null, "two")]
+ [TestCase("", "two")]
+ public static void DeletesFromGear(string stock_id1, string stock_id2) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToGear(new Gear(stock_id1), 2);
+ inv.AddToGear(new Gear(stock_id2), 4);
+
+ inv.DeleteFromGear(2);
+ inv.DeleteFromGear(4);
+
+ Assert.IsNull(inv.Gear[2], "Doesn't delete item properly from gear");
+ Assert.IsNull(inv.Gear[4], "Doesn't delete item properly from gear");
+ }
+
+ [Test]
+ [TestCase(1)]
+ [TestCase(5)]
+ [TestCase(10)]
+ public static void InstantiatesProperly(int size) {
+ Inventory inv = new Inventory(size);
+
+ Assert.AreEqual(size, inv.Hotbar.Length, "Hotbar has incorrect size");
+ Assert.AreEqual(size * size, inv.Items.Length, "Items has incorrect size");
+ Assert.AreEqual(size * 2, inv.Accessories.Length, "Accessories has incorrect size");
+ Assert.AreEqual(size, inv.Gear.Length, "Gear has incorrect size");
+ }
+
+ [Test]
+ [TestCase("one", 3)]
+ [TestCase(null, 1)]
+ [TestCase("", 4)]
+ public static void GetsProperHotbarItemTile(string stock_id, int index) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToHotbar(new Material(stock_id), index);
+
+ Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Hotbar, index).stock_id);
+ }
+
+ [Test]
+ [TestCase("one", 3)]
+ [TestCase(null, 1)]
+ [TestCase("", 4)]
+ public static void GetsProperItemsItemTile(string stock_id, int index) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToItems(new Material(stock_id), index);
+
+ Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Items, index).stock_id);
+ }
+
+ [Test]
+ [TestCase("one", 3)]
+ [TestCase(null, 1)]
+ [TestCase("", 4)]
+ public static void GetsProperAccessoriesItemTile(string stock_id, int index) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToAccessories(new Gear(stock_id), index);
+
+ Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Accessories, index).stock_id);
+ }
+
+ [Test]
+ [TestCase("one", 3)]
+ [TestCase(null, 1)]
+ [TestCase("", 4)]
+ public static void GetsProperGearItemTile(string stock_id, int index) {
+ Inventory inv = new Inventory(5);
+
+ inv.AddToGear(new Gear(stock_id), index);
+
+ Assert.AreEqual(stock_id, inv.GetItemTile(Inventory.InventoryPlace.Gear, index).stock_id);
+ }
+ }
+}
diff --git a/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs b/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs
new file mode 100644
index 0000000..b91877c
--- /dev/null
+++ b/MundusTests/ServiceTests/Tiles/Mobs/MobTileTests.cs
@@ -0,0 +1,60 @@
+using System;
+using Mundus.Data;
+using Mundus.Data.Windows;
+using Mundus.Service.Tiles.Items.Types;
+using Mundus.Service.Tiles.Mobs;
+using NUnit.Framework;
+
+namespace MundusTests.ServiceTests.Tiles.Mobs {
+ [TestFixture]
+ public static class MobTileTests {
+ [Test]
+ public static void InstantiatesProperly() {
+ MobTile mob = new MobTile("test", 10, 3, DataBaseContexts.SContext, 7, new Material("test_material"), 9);
+
+ Assert.AreEqual("test", mob.stock_id);
+ Assert.AreEqual(10, mob.Health);
+ Assert.AreEqual(3, mob.Defense);
+ Assert.AreEqual(DataBaseContexts.SContext, mob.CurrSuperLayer);
+ Assert.AreEqual(7, mob.Inventory.Hotbar.Length);
+ Assert.AreEqual("test_material", mob.DroppedUponDeath.stock_id);
+ Assert.AreEqual(9, mob.RndMovementRate);
+ }
+
+ [Test]
+ [TestCase(10, 3)]
+ [TestCase(19, 11)]
+ public static void AliveAfterTakingSmallDamage(int health, int damage) {
+ MobTile mob = new MobTile("test", health, 3, DataBaseContexts.SContext);
+
+ Assert.IsTrue(mob.TakeDamage(damage));
+ }
+
+ [Test]
+ [TestCase(10, 10)]
+ [TestCase(13, 20)]
+ public static void DeadAfterTakingBigDamage(int health, int damage) {
+ MobTile mob = new MobTile("test", health, 3, DataBaseContexts.SContext);
+
+ Assert.IsFalse(mob.TakeDamage(damage));
+ }
+
+ [Test]
+ [TestCase(10, 10)]
+ [TestCase(13, 20)]
+ public static void HealsProperly(int health, int healByPoints) {
+ MobTile mob = new MobTile("test", health, 3, DataBaseContexts.SContext);
+
+ mob.Heal(healByPoints);
+
+ if (health + healByPoints > WI.SelWin.Size * 4) {
+ Assert.AreEqual(WI.SelWin.Size, mob.Health);
+ }
+ else {
+
+ Assert.AreEqual(health + healByPoints, mob.Health);
+ }
+
+ }
+ }
+}