Skip to content

Commit a801554

Browse files
committed
Refactoring and Testing
1 parent 7c2a056 commit a801554

File tree

6 files changed

+45
-30
lines changed

6 files changed

+45
-30
lines changed

App/App.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
<UseWindowsForms>true</UseWindowsForms>
77
<AssemblyName>Blocks</AssemblyName>
88
<RootNamespace>Ragae.Game.Blocks.App</RootNamespace>
9+
<ApplicationIcon>ICON.ico</ApplicationIcon>
910
</PropertyGroup>
1011

1112
<ItemGroup>

App/ICON.ico

116 KB
Binary file not shown.

Blocks.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GameLibTest", "GameLibTest\
1717
EndProject
1818
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AppLib", "AppLib\AppLib.csproj", "{076981BD-B63D-42BF-ABF1-D5A72C9F7F55}"
1919
EndProject
20-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DataLib", "DataLib\DataLib.csproj", "{0E17919B-BB0E-45CC-9C27-F2D66CECF144}"
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DataLib", "DataLib\DataLib.csproj", "{0E17919B-BB0E-45CC-9C27-F2D66CECF144}"
2121
EndProject
2222
Global
2323
GlobalSection(SolutionConfigurationPlatforms) = preSolution

GameLibTest/GameLibTest.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@
2424
<ProjectReference Include="..\GameLib\GameLib.csproj" />
2525
</ItemGroup>
2626

27+
<ItemGroup>
28+
<Folder Include="Properties\" />
29+
</ItemGroup>
30+
2731
</Project>

GameLibTest/MovementTest.cs

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Drawing;
44
using static GameLibTest.Helper.GameLibHelper;
55
using Xunit;
6+
using System.Collections.Generic;
67

78
namespace GameLibTest
89
{
@@ -21,52 +22,61 @@ public void CreateMovement_Passing()
2122
Assert.NotNull(movement.Field);
2223
}
2324

24-
[Fact]
25-
public void CreateMovementWithEmptyFieldAndMoveDown_Passing()
25+
public static IEnumerable<object[]> GetMovementData()
2626
{
27-
Movement movement = factory.CreateMovement(factory.CreateField());
28-
29-
Assert.NotNull(movement);
30-
Assert.NotNull(movement.Field);
31-
32-
movement.Field.Current = factory.CreateFieldBrick(Color.Red);
33-
Point p = movement.Field.Current.Position;
34-
35-
Assert.True(movement.Down());
36-
Assert.True((p.Y - 1) == movement.Field.Current.Position.Y);
27+
for (int i = 0; i < 2; i++)
28+
{
29+
yield return new object[]
30+
{
31+
new List<Item[]>()
32+
{
33+
FillLine(10),
34+
FillLine(10),
35+
FillLine(10),
36+
FillLine(10)
37+
},
38+
i == 0 ? false : true
39+
};
40+
41+
yield return new object[]
42+
{
43+
new List<Item[]>()
44+
{
45+
},
46+
i == 0 ? false : true
47+
};
48+
}
3749
}
3850

39-
[Fact]
40-
public void CreateMovementWithEmptyFieldAndMoveToEnd_Passing()
51+
[Theory]
52+
[MemberData(nameof(GetMovementData))]
53+
public void CreateMovementAndMoveDownWithDifferentSettings_Passing(List<Item[]> line, bool toEnd)
4154
{
4255
Movement movement = factory.CreateMovement(factory.CreateField());
56+
movement.Field.Line.AddRange(line);
4357

4458
Assert.NotNull(movement);
4559
Assert.NotNull(movement.Field);
4660

4761
movement.Field.Current = factory.CreateFieldBrick(Color.Red);
4862

49-
while (movement.Down());
63+
int i = movement.Field.Current.Position.Y;
5064

51-
Assert.False(movement.Down());
52-
Assert.True(0 == movement.Field.Current.Position.Y);
53-
}
65+
while (movement.Down())
66+
{
67+
i--;
5468

55-
[Fact]
56-
public void CreateMovementWithFieldAndMoveToEnd_Passing()
57-
{
58-
Movement movement = factory.CreateMovement(factory.CreateField());
69+
if (!toEnd)
70+
break;
71+
}
5972

60-
Assert.NotNull(movement);
61-
Assert.NotNull(movement.Field);
62-
63-
movement.Field.Line.Add(FillLine(factory.Size.Width));
64-
movement.Field.Current = factory.CreateFieldBrick(Color.Red);
73+
Assert.Equal(toEnd, (movement.Field.Line.Count == i));
74+
Assert.Equal(toEnd, (movement.Field.Line.Count == movement.Field.Current.Position.Y));
6575

66-
while (movement.Down()) ;
76+
if (!toEnd)
77+
return;
6778

6879
Assert.False(movement.Down());
69-
Assert.True(1 == movement.Field.Current.Position.Y);
7080
}
7181
}
7282
}

ICON.ico

116 KB
Binary file not shown.

0 commit comments

Comments
 (0)