Skip to content

Commit 8675955

Browse files
Update tests (#4391)
* Update tests Adjusted per MS recommendations * Update AccountTests.cs * Update SphereTests.cs * Update SphereTests.cs
1 parent 67fbe17 commit 8675955

File tree

6 files changed

+41
-34
lines changed

6 files changed

+41
-34
lines changed

Source/ACE.DatLoader.Tests/DatTests.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
using Microsoft.VisualStudio.TestTools.UnitTesting;
77

8+
[assembly: Parallelize]
9+
810
namespace ACE.DatLoader.Tests
911
{
1012
[TestClass]
@@ -28,7 +30,7 @@ public void LoadCellDat_NoExceptions()
2830
DatDatabase dat = new DatDatabase(cellDatLocation);
2931
int count = dat.AllFiles.Count;
3032
//Assert.AreEqual(ExpectedCellDatFileCount, count);
31-
Assert.IsTrue(expectedCellDatFileCount <= count, $"Insufficient files parsed from .dat. Expected: >= {expectedCellDatFileCount}, Actual: {count}");
33+
Assert.AreEqual(expectedCellDatFileCount, count, "Insufficient files parsed from .dat.", $"{expectedCellDatFileCount}", $"{count}");
3234
}
3335

3436
[TestMethod]
@@ -40,7 +42,7 @@ public void LoadPortalDat_NoExceptions()
4042
DatDatabase dat = new DatDatabase(portalDatLocation);
4143
int count = dat.AllFiles.Count;
4244
//Assert.AreEqual(expectedPortalDatFileCount, count);
43-
Assert.IsTrue(expectedPortalDatFileCount <= count, $"Insufficient files parsed from .dat. Expected: >= {expectedPortalDatFileCount}, Actual: {count}");
45+
Assert.AreEqual(expectedPortalDatFileCount, count, "Insufficient files parsed from .dat.", $"{expectedPortalDatFileCount}", $"{count}");
4446
}
4547

4648
[TestMethod]
@@ -52,7 +54,7 @@ public void LoadLocalEnglishDat_NoExceptions()
5254
DatDatabase dat = new DatDatabase(localEnglishDatLocation);
5355
int count = dat.AllFiles.Count;
5456
//Assert.AreEqual(expectedPortalDatFileCount, count);
55-
Assert.IsTrue(expectedLocalEnglishDatFileCount <= count, $"Insufficient files parsed from .dat. Expected: >= {expectedLocalEnglishDatFileCount}, Actual: {count}");
57+
Assert.AreEqual(expectedLocalEnglishDatFileCount, count, "Insufficient files parsed from .dat.", $"{expectedLocalEnglishDatFileCount}", $"{count}");
5658
}
5759

5860

Source/ACE.Database.Tests/AccountTests.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using ACE.Entity.Enum;
99
using System.Net;
1010

11+
[assembly: DoNotParallelize]
12+
1113
namespace ACE.Database.Tests
1214
{
1315
[TestClass]
@@ -32,7 +34,7 @@ public void CreateAccount_GetAccountByName_ReturnsAccount()
3234

3335
var results = authDb.GetAccountByName(newAccount.AccountName);
3436
Assert.IsNotNull(results);
35-
Assert.IsTrue(results.AccessLevel == (uint)AccessLevel.Player);
37+
Assert.AreEqual((uint)AccessLevel.Player, results.AccessLevel);
3638
}
3739

3840
[TestMethod]
@@ -44,12 +46,12 @@ public void UpdateAccountAccessLevelToSentinelAndBackToPlayer_ReturnsAccount()
4446
authDb.UpdateAccountAccessLevel(1, AccessLevel.Sentinel);
4547
var results = authDb.GetAccountByName(newAccount.AccountName);
4648
Assert.IsNotNull(results);
47-
Assert.IsTrue(results.AccessLevel == (uint)AccessLevel.Sentinel);
49+
Assert.AreEqual((uint)AccessLevel.Sentinel, results.AccessLevel);
4850

4951
authDb.UpdateAccountAccessLevel(1, AccessLevel.Player);
5052
var results2 = authDb.GetAccountByName(newAccount.AccountName);
5153
Assert.IsNotNull(results2);
52-
Assert.IsTrue(results2.AccessLevel == (uint)AccessLevel.Player);
54+
Assert.AreEqual((uint)AccessLevel.Player, results2.AccessLevel);
5355
}
5456

5557
[TestMethod]
@@ -61,8 +63,8 @@ public void GetAccountIdByName_ReturnsAccount()
6163
var id = authDb.GetAccountIdByName(newAccount.AccountName);
6264
var results = authDb.GetAccountById(id);
6365
Assert.IsNotNull(results);
64-
Assert.IsTrue(results.AccountId == id);
65-
Assert.IsTrue(results.AccountName == newAccount.AccountName);
66+
Assert.AreEqual(id, results.AccountId);
67+
Assert.AreEqual(newAccount.AccountName, results.AccountName);
6668
}
6769

6870
[TestMethod]

Source/ACE.Database.Tests/WeenieSearchTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public void GetWeenie_Pyreal_ById_ReturnsObject()
3333
var stringName = result.WeeniePropertiesString.FirstOrDefault(x => x.Type == (ushort)PropertyString.Name)?.Value;
3434

3535
Assert.IsNotNull(result);
36-
Assert.IsTrue(stringName == "Pyreal");
37-
Assert.IsTrue(result.GetProperty(PropertyString.Name) == "Pyreal");
36+
Assert.AreEqual("Pyreal", stringName);
37+
Assert.AreEqual("Pyreal", result.GetProperty(PropertyString.Name));
3838
}
3939

4040
[TestMethod]
@@ -45,8 +45,8 @@ public void GetWeenie_Pyreal_ByName_ReturnsObject()
4545
var stringName = result.WeeniePropertiesString.FirstOrDefault(x => x.Type == (ushort)PropertyString.Name)?.Value;
4646

4747
Assert.IsNotNull(result);
48-
Assert.IsTrue(stringName == "Pyreal");
49-
Assert.IsTrue(result.GetProperty(PropertyString.Name) == "Pyreal");
48+
Assert.AreEqual("Pyreal", stringName);
49+
Assert.AreEqual("Pyreal", result.GetProperty(PropertyString.Name));
5050
}
5151
}
5252
}

Source/ACE.Server.Tests/Physics/SphereTests.cs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22
using System.Numerics;
33
using ACE.Server.Physics;
44
using ACE.Server.Physics.Animation;
5-
using ACE.Server.Physics.Collision;
65
using Microsoft.VisualStudio.TestTools.UnitTesting;
76

7+
[assembly: Parallelize]
8+
89
namespace ACE.Server.Tests.Physics
910
{
1011
[TestClass]
@@ -20,11 +21,11 @@ public void Sphere_Intersection()
2021
var sphereNonCollide = new Sphere(new Vector3(10, 10, 10), 3.0f);
2122
var sphereInside = new Sphere(new Vector3(1, 1, 1), 1.0f);
2223

23-
Assert.AreEqual(sphere.Intersects(sphereCollide), true);
24-
Assert.AreEqual(sphere.Intersects(sphereCloseCall), false);
25-
Assert.AreEqual(sphere.Intersects(sphereTouching), false);
26-
Assert.AreEqual(sphere.Intersects(sphereNonCollide), false);
27-
Assert.AreEqual(sphere.Intersects(sphereInside), true);
24+
Assert.IsTrue(sphere.Intersects(sphereCollide));
25+
Assert.IsFalse(sphere.Intersects(sphereCloseCall));
26+
Assert.IsFalse(sphere.Intersects(sphereTouching));
27+
Assert.IsFalse(sphere.Intersects(sphereNonCollide));
28+
Assert.IsTrue(sphere.Intersects(sphereInside));
2829
}
2930

3031
[TestMethod]
@@ -36,15 +37,15 @@ public void Sphere_FindTimeOfCollision()
3637
var radSum = 20.0f;
3738

3839
var time = Sphere.FindTimeOfCollision(movement, otherSpherePosition, radSum);
39-
Assert.IsTrue(time - 0.38452994616207481f < PhysicsGlobals.EPSILON);
40+
Assert.IsLessThan(PhysicsGlobals.EPSILON, time - 0.38452994616207481f);
4041

4142
otherSpherePosition = new Vector3(50, 60, 60);
4243
time = Sphere.FindTimeOfCollision(movement, otherSpherePosition, radSum);
43-
Assert.IsTrue(time - 0.46125741132772069f < PhysicsGlobals.EPSILON);
44+
Assert.IsLessThan(PhysicsGlobals.EPSILON, time - 0.46125741132772069f);
4445

4546
otherSpherePosition = new Vector3(30, 42, 63);
4647
time = Sphere.FindTimeOfCollision(movement, otherSpherePosition, radSum);
47-
Assert.IsTrue(time == -1.0f);
48+
Assert.AreEqual(-1.0f, time);
4849
}
4950

5051
[TestMethod]
@@ -90,21 +91,21 @@ public void Sphere_CollideWithPoint()
9091
var sphereNum = 0;
9192

9293
var transitionState = sphere.CollideWithPoint(transition, checkPos, radsum, sphereNum);
93-
Assert.IsTrue(transitionState == TransitionState.Collided);
94+
Assert.AreEqual(TransitionState.Collided, transitionState);
9495

9596
transition.ObjectInfo.State |= ObjectInfoState.PerfectClip;
9697
transitionState = sphere.CollideWithPoint(transition, checkPos, radsum, sphereNum);
97-
Assert.IsTrue(transitionState == TransitionState.Collided);
98+
Assert.AreEqual(TransitionState.Collided, transitionState);
9899

99100
// should redirect to location not currently in path
100101
checkPos.Center = new Vector3(30, 30, 30);
101102
transitionState = sphere.CollideWithPoint(transition, checkPos, radsum, sphereNum);
102-
Assert.IsTrue(transitionState == TransitionState.Collided);
103+
Assert.AreEqual(TransitionState.Collided, transitionState);
103104

104105
// not enough distance to make it this time
105106
transition.SpherePath.GlobalCurrCenter[0] = new Sphere(new Vector3(1, 1, 1), 5.0f);
106107
transitionState = sphere.CollideWithPoint(transition, checkPos, radsum, sphereNum);
107-
Assert.IsTrue(transitionState == TransitionState.Collided);
108+
Assert.AreEqual(TransitionState.Collided, transitionState);
108109
}
109110

110111
[TestMethod]
@@ -152,7 +153,7 @@ public void Sphere_IntersectsSphere_Inner(Sphere sphere, Transition transition,
152153
transition.SpherePath.GlobalSphere[0] = sphereNonCollide;
153154
SetCenter(transition);
154155
var transitionState = sphere.IntersectsSphere(transition, false);
155-
Assert.AreEqual(transitionState, TransitionState.OK);
156+
Assert.AreEqual(TransitionState.OK, transitionState);
156157

157158
// test collision
158159
transition.SpherePath.GlobalSphere[0] = sphereCollide;
@@ -190,13 +191,13 @@ public void Sphere_LandOnSphere()
190191

191192
// test collision
192193
var transitionState = sphere.LandOnSphere(transition);
193-
Assert.AreEqual(transitionState, TransitionState.Adjusted);
194+
Assert.AreEqual(TransitionState.Adjusted, transitionState);
194195

195196
// test adjusted
196197
transition.SpherePath.GlobalCurrCenter[0] = new Sphere(new Vector3(0, 0, 0.0001f), 5.0f);
197198
transitionState = sphere.LandOnSphere(transition);
198-
Assert.AreEqual(transitionState, TransitionState.Collided);
199-
Assert.AreEqual(transition.SpherePath.Collide, true);
199+
Assert.AreEqual(TransitionState.Collided, transitionState);
200+
Assert.IsTrue(transition.SpherePath.Collide);
200201
}
201202

202203
//[TestMethod]
@@ -227,7 +228,7 @@ public void Sphere_StepSphereDown()
227228
var checkPos = new Sphere();
228229

229230
var transitionState = sphere.StepSphereDown(transition, checkPos, ref disp, sphere.Radius * 2.0f);
230-
Assert.AreEqual(transitionState, TransitionState.Collided);
231+
Assert.AreEqual(TransitionState.Collided, transitionState);
231232
}
232233

233234
[TestMethod]
@@ -239,13 +240,13 @@ public void Sphere_SlideSphere()
239240
var transition = new Transition();
240241

241242
var transitionState = sphere.SlideSphere(transition, ref collisionNormal, Vector3.Zero);
242-
Assert.AreEqual(transitionState, TransitionState.Slid);
243+
Assert.AreEqual(TransitionState.Slid, transitionState);
243244

244245
transition.CollisionInfo.LastKnownContactPlaneValid = true;
245246
transition.CollisionInfo.LastKnownContactPlane = new Plane(new Vector3(0, 0, 1), 0);
246247

247248
transitionState = sphere.SlideSphere(transition, ref collisionNormal, Vector3.Zero);
248-
Assert.AreEqual(transitionState, TransitionState.OK);
249+
Assert.AreEqual(TransitionState.OK, transitionState);
249250
}
250251
}
251252
}

Source/ACE.Server.Tests/StarterGearTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class StarterGearTests
1616
public void CanParseStarterGearJson()
1717
{
1818
var testDir = AppContext.BaseDirectory;
19-
var starterGearPath = Path.GetFullPath(Path.Combine(testDir, "..", "..", "..", "ACE.Server", "starterGear.json"));
19+
var starterGearPath = Path.GetFullPath(Path.Combine(testDir, "..", "..", "..", "..", "..", "ACE.Server", "starterGear.json"));
2020
string contents = File.ReadAllText(starterGearPath);
2121

2222
StarterGearConfiguration config = JsonConvert.DeserializeObject<StarterGearConfiguration>(contents);

Source/ACE.Server.Tests/StartupTests.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using ACE.Database;
88
using ACE.Server.Managers;
99

10+
[assembly: DoNotParallelize]
11+
1012
namespace ACE.Server.Tests
1113
{
1214
[TestClass]
@@ -17,7 +19,7 @@ public static void TestSetup(TestContext context)
1719
{
1820
// copy config.js and initialize configuration
1921
var testDir = AppContext.BaseDirectory;
20-
var serverDir = Path.GetFullPath(Path.Combine(testDir, "..", "..", "..", "..", "ACE.Server"));
22+
var serverDir = Path.GetFullPath(Path.Combine(testDir, "..", "..", "..", "..", "..", "ACE.Server"));
2123
var configSource = Path.Combine(serverDir, "Config.js");
2224

2325
if (!File.Exists(configSource))

0 commit comments

Comments
 (0)