@@ -8,82 +8,71 @@ namespace Box2D.NetStandard.UnitTests.Dynamics.Bodies
8
8
{
9
9
public class BodyTests
10
10
{
11
- private readonly Body sut ;
11
+ private readonly Body body ;
12
12
13
13
public BodyTests ( )
14
14
{
15
- var world = new World ( ) ;
16
- var bd = new BodyDef ( ) ;
17
-
18
- sut = world . CreateBody ( bd ) ;
15
+ World world = new World ( ) ;
16
+ body = world . CreateBody ( new BodyDef ( ) ) ;
19
17
}
20
18
21
19
[ Fact ]
22
20
public void CanDestroyTopFixture ( )
23
21
{
24
- //arrange
25
- var fixtureDef = new FixtureDef ( ) { shape = new PolygonShape ( 1 , 1 ) } ;
26
- var fixture1 = sut . CreateFixture ( fixtureDef ) ;
27
- var fixture2 = sut . CreateFixture ( fixtureDef ) ;
28
- var fixture3 = sut . CreateFixture ( fixtureDef ) ;
29
-
30
- Assert . Equal ( fixture3 , sut . GetFixtureList ( ) ) ; //ensure that fixture3 is still the first in the linked list, per current implementation
22
+ FixtureDef fixtureDef = new FixtureDef ( ) { shape = new PolygonShape ( 1 , 1 ) } ;
23
+ Fixture fixture1 = body . CreateFixture ( fixtureDef ) ;
24
+ Fixture fixture2 = body . CreateFixture ( fixtureDef ) ;
25
+ Fixture fixture3 = body . CreateFixture ( fixtureDef ) ;
31
26
27
+ // Ensure that fixture3 is still the first in the linked list,
28
+ // per current implementation
29
+ Assert . Equal ( fixture3 , body . GetFixtureList ( ) ) ;
32
30
33
- //act
34
- sut . DestroyFixture ( fixture3 ) ;
31
+ body . DestroyFixture ( fixture3 ) ;
35
32
36
-
37
- //assert
38
33
Assert . Null ( fixture3 . Body ) ;
39
34
Assert . Null ( fixture3 . Next ) ;
40
- Assert . Equal ( fixture2 , sut . GetFixtureList ( ) ) ;
35
+ Assert . Equal ( fixture2 , body . GetFixtureList ( ) ) ;
41
36
Assert . Equal ( fixture1 , fixture2 . Next ) ;
42
37
}
43
38
44
39
[ Fact ]
45
40
public void CanDestroyMiddleFixture ( )
46
41
{
47
- //arrange
48
- var fixtureDef = new FixtureDef ( ) { shape = new PolygonShape ( 1 , 1 ) } ;
49
- var fixture1 = sut . CreateFixture ( fixtureDef ) ;
50
- var fixture2 = sut . CreateFixture ( fixtureDef ) ;
51
- var fixture3 = sut . CreateFixture ( fixtureDef ) ;
52
-
53
- Assert . Equal ( fixture2 , sut . GetFixtureList ( ) . Next ) ; //ensure that fixture2 is the second in the linked list, per current implementation
42
+ FixtureDef fixtureDef = new FixtureDef ( ) { shape = new PolygonShape ( 1 , 1 ) } ;
43
+ Fixture fixture1 = body . CreateFixture ( fixtureDef ) ;
44
+ Fixture fixture2 = body . CreateFixture ( fixtureDef ) ;
45
+ Fixture fixture3 = body . CreateFixture ( fixtureDef ) ;
54
46
47
+ // Ensure that fixture2 is the second in the linked list,
48
+ // per current implementation
49
+ Assert . Equal ( fixture2 , body . GetFixtureList ( ) . Next ) ;
55
50
56
- //act
57
- sut . DestroyFixture ( fixture2 ) ;
51
+ body . DestroyFixture ( fixture2 ) ;
58
52
59
-
60
- //assert
61
53
Assert . Null ( fixture2 . Body ) ;
62
54
Assert . Null ( fixture2 . Next ) ;
63
- Assert . Equal ( fixture3 , sut . GetFixtureList ( ) ) ;
55
+ Assert . Equal ( fixture3 , body . GetFixtureList ( ) ) ;
64
56
Assert . Equal ( fixture1 , fixture3 . Next ) ;
65
57
}
66
58
67
59
[ Fact ]
68
60
public void CanDestroyLastFixture ( )
69
61
{
70
- //arrange
71
- var fixtureDef = new FixtureDef ( ) { shape = new PolygonShape ( 1 , 1 ) } ;
72
- var fixture1 = sut . CreateFixture ( fixtureDef ) ;
73
- var fixture2 = sut . CreateFixture ( fixtureDef ) ;
74
- var fixture3 = sut . CreateFixture ( fixtureDef ) ;
75
-
76
- Assert . Equal ( fixture1 , sut . GetFixtureList ( ) . Next . Next ) ; //ensure that fixture1 is the third in the linked list, per current implementation
77
-
62
+ FixtureDef fixtureDef = new FixtureDef ( ) { shape = new PolygonShape ( 1 , 1 ) } ;
63
+ Fixture fixture1 = body . CreateFixture ( fixtureDef ) ;
64
+ Fixture fixture2 = body . CreateFixture ( fixtureDef ) ;
65
+ Fixture fixture3 = body . CreateFixture ( fixtureDef ) ;
78
66
79
- //act
80
- sut . DestroyFixture ( fixture1 ) ;
67
+ // Ensure that fixture1 is the third in the linked list,
68
+ // per current implementation
69
+ Assert . Equal ( fixture1 , body . GetFixtureList ( ) . Next . Next ) ;
81
70
71
+ body . DestroyFixture ( fixture1 ) ;
82
72
83
- //assert
84
73
Assert . Null ( fixture1 . Body ) ;
85
74
Assert . Null ( fixture1 . Next ) ;
86
- Assert . Equal ( fixture3 , sut . GetFixtureList ( ) ) ;
75
+ Assert . Equal ( fixture3 , body . GetFixtureList ( ) ) ;
87
76
Assert . Equal ( fixture2 , fixture3 . Next ) ;
88
77
}
89
78
}
0 commit comments