diff options
Diffstat (limited to 'Plugins/MonoGame.Extended/tests/MonoGame.Extended.Collisions.Tests/SpatialHashTests.cs')
-rw-r--r-- | Plugins/MonoGame.Extended/tests/MonoGame.Extended.Collisions.Tests/SpatialHashTests.cs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Collisions.Tests/SpatialHashTests.cs b/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Collisions.Tests/SpatialHashTests.cs new file mode 100644 index 0000000..7c09a9e --- /dev/null +++ b/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Collisions.Tests/SpatialHashTests.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using System.Linq; +using Xunit; + +namespace MonoGame.Extended.Collisions.Tests; + +public class SpatialHashTests +{ + private SpatialHash generateSpatialHash() => new SpatialHash(new Size2(64, 64)); + private readonly RectangleF RECT = new RectangleF(10, 10, 20, 20); + + [Fact] + public void CollisionOneTrueTest() + { + var hash = generateSpatialHash(); + hash.Insert(new BasicActor() + { + Bounds = RECT, + }); + var collisions = hash.Query(RECT); + Assert.Equal(1, collisions.Count()); + } + + [Fact] + public void CollisionTwoTest() + { + var hash = generateSpatialHash(); + hash.Insert(new BasicActor + { + Bounds = RECT, + }); + hash.Insert(new BasicActor + { + Bounds = RECT, + }); + var collisions = hash.Query(RECT); + Assert.Equal(2, collisions.Count()); + } +} |