@@ -7,47 +7,59 @@ namespace BulletSharpTest
77 [ Category ( "AlignedObjectArray" ) ]
88 class AlignedCollisionObjectArrayTests
99 {
10- private DefaultCollisionConfiguration _conf ;
11- private CollisionDispatcher _dispatcher ;
12- private DbvtBroadphase _broadphase ;
13- private SequentialImpulseConstraintSolver _solver ;
14- private DiscreteDynamicsWorld _world ;
10+ private PhysicsContext _context ;
1511 private CollisionShape _shape ;
1612 private RigidBody _body1 ;
1713 private RigidBody _body2 ;
1814 private RigidBody _body3 ;
1915
16+ [ OneTimeSetUp ]
17+ public void SetUp ( )
18+ {
19+ _context = new PhysicsContext ( ) ;
20+ _context . InitializeWorld ( ) ;
21+
22+ _shape = new BoxShape ( 1 ) ;
23+ using ( var bodyInfo = new RigidBodyConstructionInfo ( 1 , null , _shape ) )
24+ {
25+ _body1 = new RigidBody ( bodyInfo ) ;
26+ _body2 = new RigidBody ( bodyInfo ) ;
27+ _body3 = new RigidBody ( bodyInfo ) ;
28+ }
29+ }
30+
2031 [ Test ]
2132 public void AlignedCollisionObjectArrayTest ( )
2233 {
23- var worldArray = _world . CollisionObjectArray ;
34+ var world = _context . World ;
35+ var worldArray = world . CollisionObjectArray ;
2436 Assert . IsEmpty ( worldArray ) ;
2537
26- _world . AddRigidBody ( _body1 ) ;
27- _world . AddRigidBody ( _body2 ) ;
38+ world . AddRigidBody ( _body1 ) ;
39+ world . AddRigidBody ( _body2 ) ;
2840 Assert . That ( worldArray , Has . Count . EqualTo ( 2 ) ) ;
29- Assert . AreEqual ( 2 , _world . NumCollisionObjects ) ;
41+ Assert . AreEqual ( 2 , world . NumCollisionObjects ) ;
3042
3143 Assert . True ( worldArray . Contains ( _body1 ) ) ;
3244 Assert . True ( worldArray . Contains ( _body2 ) ) ;
3345
3446 Assert . AreEqual ( 0 , worldArray . IndexOf ( _body1 ) ) ;
3547 Assert . AreEqual ( 1 , worldArray . IndexOf ( _body2 ) ) ;
3648
37- _world . RemoveRigidBody ( _body1 ) ;
49+ world . RemoveRigidBody ( _body1 ) ;
3850 Assert . That ( worldArray , Has . Count . EqualTo ( 1 ) ) ;
39- Assert . AreEqual ( 1 , _world . NumCollisionObjects ) ;
51+ Assert . AreEqual ( 1 , world . NumCollisionObjects ) ;
4052
41- _world . RemoveRigidBody ( _body1 ) ;
53+ world . RemoveRigidBody ( _body1 ) ;
4254 Assert . That ( worldArray , Has . Count . EqualTo ( 1 ) ) ;
43- Assert . AreEqual ( 1 , _world . NumCollisionObjects ) ;
55+ Assert . AreEqual ( 1 , world . NumCollisionObjects ) ;
4456
4557 worldArray . Remove ( _body2 ) ;
46- Assert . AreEqual ( 0 , _world . NumCollisionObjects ) ;
58+ Assert . AreEqual ( 0 , world . NumCollisionObjects ) ;
4759
48- _world . AddRigidBody ( _body1 ) ;
49- _world . AddRigidBody ( _body2 ) ;
50- _world . AddRigidBody ( _body3 ) ;
60+ world . AddRigidBody ( _body1 ) ;
61+ world . AddRigidBody ( _body2 ) ;
62+ world . AddRigidBody ( _body3 ) ;
5163 worldArray . RemoveAt ( 0 ) ;
5264 Assert . False ( _body1 . IsInWorld ) ;
5365 Assert . AreEqual ( _body3 , worldArray [ 0 ] ) ;
@@ -57,37 +69,15 @@ public void AlignedCollisionObjectArrayTest()
5769 Assert . AreEqual ( - 1 , worldArray . IndexOf ( null ) ) ;
5870
5971 worldArray . Clear ( ) ;
60- Assert . AreEqual ( 0 , _world . NumCollisionObjects ) ;
72+ Assert . AreEqual ( 0 , world . NumCollisionObjects ) ;
6173 Assert . False ( _body2 . IsInWorld ) ;
6274 Assert . False ( _body3 . IsInWorld ) ;
6375 }
6476
65- [ OneTimeSetUp ]
66- public void SetUp ( )
67- {
68- _conf = new DefaultCollisionConfiguration ( ) ;
69- _dispatcher = new CollisionDispatcher ( _conf ) ;
70- _broadphase = new DbvtBroadphase ( ) ;
71- _solver = new SequentialImpulseConstraintSolver ( ) ;
72- _world = new DiscreteDynamicsWorld ( _dispatcher , _broadphase , _solver , _conf ) ;
73-
74- _shape = new BoxShape ( 1 ) ;
75- using ( var bodyInfo = new RigidBodyConstructionInfo ( 1 , null , _shape ) )
76- {
77- _body1 = new RigidBody ( bodyInfo ) ;
78- _body2 = new RigidBody ( bodyInfo ) ;
79- _body3 = new RigidBody ( bodyInfo ) ;
80- }
81- }
82-
8377 [ OneTimeTearDown ]
8478 public void TearDown ( )
8579 {
86- _world . Dispose ( ) ;
87- _solver . Dispose ( ) ;
88- _broadphase . Dispose ( ) ;
89- _dispatcher . Dispose ( ) ;
90- _conf . Dispose ( ) ;
80+ _context . Dispose ( ) ;
9181
9282 _shape . Dispose ( ) ;
9383 _body1 . Dispose ( ) ;
0 commit comments