Skip to content

Commit c3d4cd4

Browse files
committed
Cleanup tests
1 parent 8e47ebc commit c3d4cd4

File tree

5 files changed

+33
-45
lines changed

5 files changed

+33
-45
lines changed

src/box2dx/Box2D.NetStandard.UnitTests/AddPairTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Box2D.NetStandard.UnitTests
88
public class AddPairTest
99
{
1010
[Fact]
11-
public void AddPairs()
11+
public void Test()
1212
{
1313
for (int j = 0; j < 1; j++)
1414
{

src/box2dx/Box2D.NetStandard.UnitTests/CarTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public CarTest(ITestOutputHelper output)
1818

1919
// TODO: Fix because the test isn't working correctly
2020
// [Fact]
21-
public void CarTest1()
21+
public void Test()
2222
{
2323
World world = CarWorld.CreateWorld(out Body[] bodies, out Joint[] joints);
2424

src/box2dx/Box2D.NetStandard.UnitTests/Dynamics/Bodies/BodyTests.cs

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,82 +8,71 @@ namespace Box2D.NetStandard.UnitTests.Dynamics.Bodies
88
{
99
public class BodyTests
1010
{
11-
private readonly Body sut;
11+
private readonly Body body;
1212

1313
public BodyTests()
1414
{
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());
1917
}
2018

2119
[Fact]
2220
public void CanDestroyTopFixture()
2321
{
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);
3126

27+
// Ensure that fixture3 is still the first in the linked list,
28+
// per current implementation
29+
Assert.Equal(fixture3, body.GetFixtureList());
3230

33-
//act
34-
sut.DestroyFixture(fixture3);
31+
body.DestroyFixture(fixture3);
3532

36-
37-
//assert
3833
Assert.Null(fixture3.Body);
3934
Assert.Null(fixture3.Next);
40-
Assert.Equal(fixture2, sut.GetFixtureList());
35+
Assert.Equal(fixture2, body.GetFixtureList());
4136
Assert.Equal(fixture1, fixture2.Next);
4237
}
4338

4439
[Fact]
4540
public void CanDestroyMiddleFixture()
4641
{
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);
5446

47+
// Ensure that fixture2 is the second in the linked list,
48+
// per current implementation
49+
Assert.Equal(fixture2, body.GetFixtureList().Next);
5550

56-
//act
57-
sut.DestroyFixture(fixture2);
51+
body.DestroyFixture(fixture2);
5852

59-
60-
//assert
6153
Assert.Null(fixture2.Body);
6254
Assert.Null(fixture2.Next);
63-
Assert.Equal(fixture3, sut.GetFixtureList());
55+
Assert.Equal(fixture3, body.GetFixtureList());
6456
Assert.Equal(fixture1, fixture3.Next);
6557
}
6658

6759
[Fact]
6860
public void CanDestroyLastFixture()
6961
{
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);
7866

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);
8170

71+
body.DestroyFixture(fixture1);
8272

83-
//assert
8473
Assert.Null(fixture1.Body);
8574
Assert.Null(fixture1.Next);
86-
Assert.Equal(fixture3, sut.GetFixtureList());
75+
Assert.Equal(fixture3, body.GetFixtureList());
8776
Assert.Equal(fixture2, fixture3.Next);
8877
}
8978
}

src/box2dx/Box2D.NetStandard.UnitTests/RubeGoldbergTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public RubeGoldbergTest(ITestOutputHelper output)
1818

1919
// TODO: Fix because the test isn't working correctly
2020
// [Fact]
21-
public void Test1()
21+
public void Test()
2222
{
2323
World world = RubeGoldbergWorld.CreateWorld(out Body[] bodies, out Joint[] joints);
2424

src/box2dx/Box2D.NetStandard.UnitTests/SetLinearVelocityTest.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ public void TestOnlyOneBodyGetsVelocity()
6262
Assert.True((starting1.Y - ending1.Y) < 0.01f);
6363
// It should have moved left
6464
Assert.True(ending1.X < starting1.X);
65-
6665
// Body 2 should not have moved
6766
Assert.Equal(starting2, ending2);
6867
}

0 commit comments

Comments
 (0)