aboutsummaryrefslogtreecommitdiff
path: root/MundusTests/DataTests/SuperLayers/SkyContextTests.cs
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 /MundusTests/DataTests/SuperLayers/SkyContextTests.cs
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.
Diffstat (limited to 'MundusTests/DataTests/SuperLayers/SkyContextTests.cs')
-rw-r--r--MundusTests/DataTests/SuperLayers/SkyContextTests.cs187
1 files changed, 94 insertions, 93 deletions
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");
+ //}
}
}