3
3
using System . Drawing ;
4
4
using static GameLibTest . Helper . GameLibHelper ;
5
5
using Xunit ;
6
+ using System . Collections . Generic ;
6
7
7
8
namespace GameLibTest
8
9
{
@@ -21,52 +22,61 @@ public void CreateMovement_Passing()
21
22
Assert . NotNull ( movement . Field ) ;
22
23
}
23
24
24
- [ Fact ]
25
- public void CreateMovementWithEmptyFieldAndMoveDown_Passing ( )
25
+ public static IEnumerable < object [ ] > GetMovementData ( )
26
26
{
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
+ }
37
49
}
38
50
39
- [ Fact ]
40
- public void CreateMovementWithEmptyFieldAndMoveToEnd_Passing ( )
51
+ [ Theory ]
52
+ [ MemberData ( nameof ( GetMovementData ) ) ]
53
+ public void CreateMovementAndMoveDownWithDifferentSettings_Passing ( List < Item [ ] > line , bool toEnd )
41
54
{
42
55
Movement movement = factory . CreateMovement ( factory . CreateField ( ) ) ;
56
+ movement . Field . Line . AddRange ( line ) ;
43
57
44
58
Assert . NotNull ( movement ) ;
45
59
Assert . NotNull ( movement . Field ) ;
46
60
47
61
movement . Field . Current = factory . CreateFieldBrick ( Color . Red ) ;
48
62
49
- while ( movement . Down ( ) ) ;
63
+ int i = movement . Field . Current . Position . Y ;
50
64
51
- Assert . False ( movement . Down ( ) ) ;
52
- Assert . True ( 0 == movement . Field . Current . Position . Y ) ;
53
- }
65
+ while ( movement . Down ( ) )
66
+ {
67
+ i -- ;
54
68
55
- [ Fact ]
56
- public void CreateMovementWithFieldAndMoveToEnd_Passing ( )
57
- {
58
- Movement movement = factory . CreateMovement ( factory . CreateField ( ) ) ;
69
+ if ( ! toEnd )
70
+ break ;
71
+ }
59
72
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 ) ) ;
65
75
66
- while ( movement . Down ( ) ) ;
76
+ if ( ! toEnd )
77
+ return ;
67
78
68
79
Assert . False ( movement . Down ( ) ) ;
69
- Assert . True ( 1 == movement . Field . Current . Position . Y ) ;
70
80
}
71
81
}
72
82
}
0 commit comments