diff options
author | chai <215380520@qq.com> | 2024-06-03 10:15:45 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2024-06-03 10:15:45 +0800 |
commit | acea7b2e728787a0d83bbf83c8c1f042d2c32e7e (patch) | |
tree | 0bfec05c1ca2d71be2c337bcd110a0421f19318b /Plugins/MonoGame.Extended/tests/MonoGame.Extended.Entities.Tests/AspectBuilderTests.cs | |
parent | 88febcb02bf127d961c6471d9e846c0e1315f5c3 (diff) |
+ plugins project
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.cs | 70 |
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 |