aboutsummaryrefslogtreecommitdiff
path: root/MundusTests/DataTests
diff options
context:
space:
mode:
Diffstat (limited to 'MundusTests/DataTests')
-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
5 files changed, 288 insertions, 302 deletions
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");
+ //}
}
}