@@ -22,7 +22,7 @@ public class ObservableGroupTests
22
22
public void should_include_entity_snapshot_on_creation ( )
23
23
{
24
24
var mockCollectionNotifier = Substitute . For < INotifyingEntityCollection > ( ) ;
25
- var accessorToken = new ObservableGroupToken ( new Type [ ] { typeof ( TestComponentOne ) } , new Type [ 0 ] , "default" ) ;
25
+ var accessorToken = new ObservableGroupToken ( new [ ] { 1 } , new int [ 0 ] , "default" ) ;
26
26
27
27
var applicableEntity1 = Substitute . For < IEntity > ( ) ;
28
28
var applicableEntity2 = Substitute . For < IEntity > ( ) ;
@@ -32,9 +32,9 @@ public void should_include_entity_snapshot_on_creation()
32
32
applicableEntity2 . Id . Returns ( 2 ) ;
33
33
notApplicableEntity1 . Id . Returns ( 3 ) ;
34
34
35
- applicableEntity1 . HasComponent ( Arg . Any < Type > ( ) ) . Returns ( true ) ;
36
- applicableEntity2 . HasComponent ( Arg . Any < Type > ( ) ) . Returns ( true ) ;
37
- notApplicableEntity1 . HasComponent ( Arg . Any < Type > ( ) ) . Returns ( false ) ;
35
+ applicableEntity1 . HasComponent ( Arg . Any < int > ( ) ) . Returns ( true ) ;
36
+ applicableEntity2 . HasComponent ( Arg . Any < int > ( ) ) . Returns ( true ) ;
37
+ notApplicableEntity1 . HasComponent ( Arg . Any < int > ( ) ) . Returns ( false ) ;
38
38
39
39
var dummyEntitySnapshot = new List < IEntity >
40
40
{
@@ -60,17 +60,17 @@ public void should_include_entity_snapshot_on_creation()
60
60
public void should_add_entity_and_raise_event_when_applicable_entity_added ( )
61
61
{
62
62
var collectionName = "default" ;
63
- var accessorToken = new ObservableGroupToken ( new [ ] { typeof ( TestComponentOne ) , typeof ( TestComponentTwo ) } , new Type [ 0 ] , collectionName ) ;
63
+ var accessorToken = new ObservableGroupToken ( new [ ] { 1 , 2 } , new int [ 0 ] , collectionName ) ;
64
64
var mockCollection = Substitute . For < IEntityCollection > ( ) ;
65
65
mockCollection . Name . Returns ( collectionName ) ;
66
66
67
67
var applicableEntity = Substitute . For < IEntity > ( ) ;
68
68
applicableEntity . Id . Returns ( 1 ) ;
69
- applicableEntity . HasComponent ( Arg . Is < Type > ( x => accessorToken . Group . RequiredComponents . Contains ( x ) ) ) . Returns ( true ) ;
69
+ applicableEntity . HasComponent ( Arg . Is < int > ( x => accessorToken . LookupGroup . RequiredComponents . Contains ( x ) ) ) . Returns ( true ) ;
70
70
71
71
var unapplicableEntity = Substitute . For < IEntity > ( ) ;
72
72
unapplicableEntity . Id . Returns ( 2 ) ;
73
- unapplicableEntity . HasComponent ( Arg . Is < Type > ( x => accessorToken . Group . RequiredComponents . Contains ( x ) ) ) . Returns ( false ) ;
73
+ unapplicableEntity . HasComponent ( Arg . Is < int > ( x => accessorToken . LookupGroup . RequiredComponents . Contains ( x ) ) ) . Returns ( false ) ;
74
74
75
75
var mockCollectionNotifier = Substitute . For < INotifyingEntityCollection > ( ) ;
76
76
@@ -99,7 +99,7 @@ public void should_add_entity_and_raise_event_when_applicable_entity_added()
99
99
public void should_add_entity_and_raise_event_when_components_match_group ( )
100
100
{
101
101
var collectionName = "default" ;
102
- var accessorToken = new ObservableGroupToken ( new [ ] { typeof ( TestComponentOne ) } , new [ ] { typeof ( TestComponentTwo ) } , collectionName ) ;
102
+ var accessorToken = new ObservableGroupToken ( new [ ] { 1 } , new [ ] { 2 } , collectionName ) ;
103
103
var mockCollection = Substitute . For < IEntityCollection > ( ) ;
104
104
mockCollection . Name . Returns ( collectionName ) ;
105
105
@@ -119,8 +119,8 @@ public void should_add_entity_and_raise_event_when_components_match_group()
119
119
var wasCalled = 0 ;
120
120
observableGroup . OnEntityAdded . Subscribe ( x => wasCalled ++ ) ;
121
121
122
- applicableEntity . HasAllComponents ( accessorToken . Group . RequiredComponents ) . Returns ( true ) ;
123
- applicableEntity . HasAnyComponents ( accessorToken . Group . ExcludedComponents ) . Returns ( false ) ;
122
+ applicableEntity . HasAllComponents ( accessorToken . LookupGroup . RequiredComponents ) . Returns ( true ) ;
123
+ applicableEntity . HasAnyComponents ( accessorToken . LookupGroup . ExcludedComponents ) . Returns ( false ) ;
124
124
componentRemoved . OnNext ( new ComponentsChangedEvent ( mockCollection , applicableEntity , null ) ) ;
125
125
126
126
Assert . Contains ( applicableEntity , observableGroup . CachedEntities . Values ) ;
@@ -131,14 +131,14 @@ public void should_add_entity_and_raise_event_when_components_match_group()
131
131
public void should_remove_entity_and_raise_events_when_entity_removed_with_components ( )
132
132
{
133
133
var collectionName = "default" ;
134
- var accessorToken = new ObservableGroupToken ( new [ ] { typeof ( TestComponentOne ) , typeof ( TestComponentTwo ) } , new Type [ 0 ] , collectionName ) ;
134
+ var accessorToken = new ObservableGroupToken ( new [ ] { 1 , 2 } , new int [ 0 ] , collectionName ) ;
135
135
var mockCollection = Substitute . For < IEntityCollection > ( ) ;
136
136
mockCollection . Name . Returns ( collectionName ) ;
137
137
138
138
var applicableEntity = Substitute . For < IEntity > ( ) ;
139
139
applicableEntity . Id . Returns ( 1 ) ;
140
- applicableEntity . HasComponent ( Arg . Is < Type > ( x => accessorToken . Group . RequiredComponents . Contains ( x ) ) ) . Returns ( true ) ;
141
- applicableEntity . HasComponent ( Arg . Is < Type > ( x => accessorToken . Group . ExcludedComponents . Contains ( x ) ) ) . Returns ( false ) ;
140
+ applicableEntity . HasComponent ( Arg . Is < int > ( x => accessorToken . LookupGroup . RequiredComponents . Contains ( x ) ) ) . Returns ( true ) ;
141
+ applicableEntity . HasComponent ( Arg . Is < int > ( x => accessorToken . LookupGroup . ExcludedComponents . Contains ( x ) ) ) . Returns ( false ) ;
142
142
143
143
var mockCollectionNotifier = Substitute . For < INotifyingEntityCollection > ( ) ;
144
144
@@ -156,7 +156,7 @@ public void should_remove_entity_and_raise_events_when_entity_removed_with_compo
156
156
var wasRemovedCalled = 0 ;
157
157
observableGroup . OnEntityRemoved . Subscribe ( x => wasRemovedCalled ++ ) ;
158
158
159
- componentRemoving . OnNext ( new ComponentsChangedEvent ( null , applicableEntity , new [ ] { typeof ( TestComponentOne ) } ) ) ;
159
+ componentRemoving . OnNext ( new ComponentsChangedEvent ( null , applicableEntity , new [ ] { 1 } ) ) ;
160
160
161
161
Assert . Contains ( applicableEntity , observableGroup . CachedEntities . Values ) ;
162
162
Assert . Equal ( 1 , wasRemovingCalled ) ;
@@ -174,14 +174,14 @@ public void should_remove_entity_and_raise_events_when_entity_removed_with_compo
174
174
public void should_remove_entity_and_raise_event_when_no_longer_matches_group ( )
175
175
{
176
176
var collectionName = "default" ;
177
- var accessorToken = new ObservableGroupToken ( new [ ] { typeof ( TestComponentOne ) , typeof ( TestComponentTwo ) } , new Type [ 0 ] , collectionName ) ;
177
+ var accessorToken = new ObservableGroupToken ( new [ ] { 1 , 2 } , new int [ 0 ] , collectionName ) ;
178
178
var mockCollection = Substitute . For < IEntityCollection > ( ) ;
179
179
mockCollection . Name . Returns ( collectionName ) ;
180
180
181
181
var applicableEntity = Substitute . For < IEntity > ( ) ;
182
182
applicableEntity . Id . Returns ( 1 ) ;
183
- applicableEntity . HasComponent ( Arg . Is < Type > ( x => accessorToken . Group . RequiredComponents . Contains ( x ) ) ) . Returns ( true ) ;
184
- applicableEntity . HasComponent ( Arg . Is < Type > ( x => accessorToken . Group . ExcludedComponents . Contains ( x ) ) ) . Returns ( false ) ;
183
+ applicableEntity . HasComponent ( Arg . Is < int > ( x => accessorToken . LookupGroup . RequiredComponents . Contains ( x ) ) ) . Returns ( true ) ;
184
+ applicableEntity . HasComponent ( Arg . Is < int > ( x => accessorToken . LookupGroup . ExcludedComponents . Contains ( x ) ) ) . Returns ( false ) ;
185
185
186
186
var mockCollectionNotifier = Substitute . For < INotifyingEntityCollection > ( ) ;
187
187
@@ -201,10 +201,10 @@ public void should_remove_entity_and_raise_event_when_no_longer_matches_group()
201
201
var wasRemovedCalled = 0 ;
202
202
observableGroup . OnEntityRemoved . Subscribe ( x => wasRemovedCalled ++ ) ;
203
203
204
- applicableEntity . HasAnyComponents ( accessorToken . Group . RequiredComponents ) . Returns ( false ) ;
205
- applicableEntity . HasAllComponents ( accessorToken . Group . RequiredComponents ) . Returns ( false ) ;
206
- componentRemoving . OnNext ( new ComponentsChangedEvent ( mockCollection , applicableEntity , new [ ] { typeof ( TestComponentOne ) } ) ) ;
207
- componentRemoved . OnNext ( new ComponentsChangedEvent ( mockCollection , applicableEntity , new [ ] { typeof ( TestComponentOne ) } ) ) ;
204
+ applicableEntity . HasAnyComponents ( accessorToken . LookupGroup . RequiredComponents ) . Returns ( false ) ;
205
+ applicableEntity . HasAllComponents ( accessorToken . LookupGroup . RequiredComponents ) . Returns ( false ) ;
206
+ componentRemoving . OnNext ( new ComponentsChangedEvent ( mockCollection , applicableEntity , new [ ] { 1 } ) ) ;
207
+ componentRemoved . OnNext ( new ComponentsChangedEvent ( mockCollection , applicableEntity , new [ ] { 1 } ) ) ;
208
208
209
209
Assert . DoesNotContain ( applicableEntity , observableGroup . CachedEntities . Values ) ;
210
210
Assert . Equal ( 1 , wasRemovingCalled ) ;
0 commit comments