1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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);
}
}
}
|