summaryrefslogtreecommitdiff
path: root/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs')
-rw-r--r--Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs70
1 files changed, 70 insertions, 0 deletions
diff --git a/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs b/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs
new file mode 100644
index 0000000..1b3e971
--- /dev/null
+++ b/Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs
@@ -0,0 +1,70 @@
+using System;
+using Microsoft.Xna.Framework.Graphics;
+using MonoGame.Extended.Sprites;
+using Xunit;
+
+namespace MonoGame.Extended.Entities.Tests
+{
+ public class AspectBuilderTests
+ {
+ [Fact]
+ public void MatchAllTypes()
+ {
+ var builder = new AspectBuilder()
+ .All(typeof(Transform2), typeof(Sprite));
+
+ Assert.Equal(2, builder.AllTypes.Count);
+ Assert.Contains(typeof(Transform2), builder.AllTypes);
+ Assert.Contains(typeof(Sprite), builder.AllTypes);
+ }
+
+ [Fact]
+ public void MatchAllTypesIsEmpty()
+ {
+ var builder = new AspectBuilder()
+ .All();
+
+ Assert.Empty(builder.AllTypes);
+ Assert.Empty(builder.OneTypes);
+ Assert.Empty(builder.ExclusionTypes);
+ }
+
+ [Fact]
+ public void MatchOneOfType()
+ {
+ var builder = new AspectBuilder()
+ .One(typeof(Transform2), typeof(Sprite));
+
+ Assert.Equal(2, builder.OneTypes.Count);
+ Assert.Contains(typeof(Transform2), builder.OneTypes);
+ Assert.Contains(typeof(Sprite), builder.OneTypes);
+ }
+
+ [Fact]
+ public void ExcludeTypes()
+ {
+ var builder = new AspectBuilder()
+ .Exclude(typeof(Transform2), typeof(Sprite));
+
+ Assert.Equal(2, builder.ExclusionTypes.Count);
+ Assert.Contains(typeof(Transform2), builder.ExclusionTypes);
+ Assert.Contains(typeof(Sprite), builder.ExclusionTypes);
+ }
+
+ [Fact]
+ public void BuildAspect()
+ {
+ var componentManager = new ComponentManager();
+ var builder = new AspectBuilder()
+ .All(typeof(Transform2), typeof(Sprite))
+ .One(typeof(string))
+ .Exclude(typeof(Texture2D));
+
+ var aspect = builder.Build(componentManager);
+
+ Assert.True(aspect.AllSet.Data != 0);
+ Assert.True(aspect.OneSet.Data != 0);
+ Assert.True(aspect.ExclusionSet.Data != 0);
+ }
+ }
+} \ No newline at end of file