|
1 | | -using System; |
2 | 1 | using Xunit; |
3 | 2 |
|
4 | 3 | public class GameOfLifeTests |
5 | 4 | { |
6 | 5 | [Fact] |
7 | 6 | public void Empty_matrix() |
8 | 7 | { |
9 | | - var matrix = new int[,] { }; |
| 8 | + int[,] matrix = |
| 9 | + { |
| 10 | + }; |
10 | 11 | Assert.Empty(GameOfLife.Tick(matrix)); |
11 | 12 | } |
12 | 13 |
|
13 | 14 | [Fact(Skip = "Remove this Skip property to run this test")] |
14 | 15 | public void Live_cells_with_zero_live_neighbors_die() |
15 | 16 | { |
16 | | - var matrix = new[,] |
| 17 | + int[,] matrix = |
17 | 18 | { |
18 | | - { 0, 0, 0 }, |
19 | | - { 0, 1, 0 }, |
20 | | - { 0, 0, 0 } |
| 19 | + { 0, 0, 0 }, |
| 20 | + { 0, 1, 0 }, |
| 21 | + { 0, 0, 0 } |
21 | 22 | }; |
22 | | - var expected = new[,] |
| 23 | + int[,] expected = |
23 | 24 | { |
24 | | - { 0, 0, 0 }, |
25 | | - { 0, 0, 0 }, |
26 | | - { 0, 0, 0 } |
| 25 | + { 0, 0, 0 }, |
| 26 | + { 0, 0, 0 }, |
| 27 | + { 0, 0, 0 } |
27 | 28 | }; |
28 | 29 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
29 | 30 | } |
30 | 31 |
|
31 | 32 | [Fact(Skip = "Remove this Skip property to run this test")] |
32 | 33 | public void Live_cells_with_only_one_live_neighbor_die() |
33 | 34 | { |
34 | | - var matrix = new[,] |
| 35 | + int[,] matrix = |
35 | 36 | { |
36 | | - { 0, 0, 0 }, |
37 | | - { 0, 1, 0 }, |
38 | | - { 0, 1, 0 } |
| 37 | + { 0, 0, 0 }, |
| 38 | + { 0, 1, 0 }, |
| 39 | + { 0, 1, 0 } |
39 | 40 | }; |
40 | | - var expected = new[,] |
| 41 | + int[,] expected = |
41 | 42 | { |
42 | | - { 0, 0, 0 }, |
43 | | - { 0, 0, 0 }, |
44 | | - { 0, 0, 0 } |
| 43 | + { 0, 0, 0 }, |
| 44 | + { 0, 0, 0 }, |
| 45 | + { 0, 0, 0 } |
45 | 46 | }; |
46 | 47 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
47 | 48 | } |
48 | 49 |
|
49 | 50 | [Fact(Skip = "Remove this Skip property to run this test")] |
50 | 51 | public void Live_cells_with_two_live_neighbors_stay_alive() |
51 | 52 | { |
52 | | - var matrix = new[,] |
| 53 | + int[,] matrix = |
53 | 54 | { |
54 | | - { 1, 0, 1 }, |
55 | | - { 1, 0, 1 }, |
56 | | - { 1, 0, 1 } |
| 55 | + { 1, 0, 1 }, |
| 56 | + { 1, 0, 1 }, |
| 57 | + { 1, 0, 1 } |
57 | 58 | }; |
58 | | - var expected = new[,] |
| 59 | + int[,] expected = |
59 | 60 | { |
60 | | - { 0, 0, 0 }, |
61 | | - { 1, 0, 1 }, |
62 | | - { 0, 0, 0 } |
| 61 | + { 0, 0, 0 }, |
| 62 | + { 1, 0, 1 }, |
| 63 | + { 0, 0, 0 } |
63 | 64 | }; |
64 | 65 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
65 | 66 | } |
66 | 67 |
|
67 | 68 | [Fact(Skip = "Remove this Skip property to run this test")] |
68 | 69 | public void Live_cells_with_three_live_neighbors_stay_alive() |
69 | 70 | { |
70 | | - var matrix = new[,] |
| 71 | + int[,] matrix = |
71 | 72 | { |
72 | | - { 0, 1, 0 }, |
73 | | - { 1, 0, 0 }, |
74 | | - { 1, 1, 0 } |
| 73 | + { 0, 1, 0 }, |
| 74 | + { 1, 0, 0 }, |
| 75 | + { 1, 1, 0 } |
75 | 76 | }; |
76 | | - var expected = new[,] |
| 77 | + int[,] expected = |
77 | 78 | { |
78 | | - { 0, 0, 0 }, |
79 | | - { 1, 0, 0 }, |
80 | | - { 1, 1, 0 } |
| 79 | + { 0, 0, 0 }, |
| 80 | + { 1, 0, 0 }, |
| 81 | + { 1, 1, 0 } |
81 | 82 | }; |
82 | 83 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
83 | 84 | } |
84 | 85 |
|
85 | 86 | [Fact(Skip = "Remove this Skip property to run this test")] |
86 | 87 | public void Dead_cells_with_three_live_neighbors_become_alive() |
87 | 88 | { |
88 | | - var matrix = new[,] |
| 89 | + int[,] matrix = |
89 | 90 | { |
90 | | - { 1, 1, 0 }, |
91 | | - { 0, 0, 0 }, |
92 | | - { 1, 0, 0 } |
| 91 | + { 1, 1, 0 }, |
| 92 | + { 0, 0, 0 }, |
| 93 | + { 1, 0, 0 } |
93 | 94 | }; |
94 | | - var expected = new[,] |
| 95 | + int[,] expected = |
95 | 96 | { |
96 | | - { 0, 0, 0 }, |
97 | | - { 1, 1, 0 }, |
98 | | - { 0, 0, 0 } |
| 97 | + { 0, 0, 0 }, |
| 98 | + { 1, 1, 0 }, |
| 99 | + { 0, 0, 0 } |
99 | 100 | }; |
100 | 101 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
101 | 102 | } |
102 | 103 |
|
103 | 104 | [Fact(Skip = "Remove this Skip property to run this test")] |
104 | 105 | public void Live_cells_with_four_or_more_neighbors_die() |
105 | 106 | { |
106 | | - var matrix = new[,] |
| 107 | + int[,] matrix = |
107 | 108 | { |
108 | | - { 1, 1, 1 }, |
109 | | - { 1, 1, 1 }, |
110 | | - { 1, 1, 1 } |
| 109 | + { 1, 1, 1 }, |
| 110 | + { 1, 1, 1 }, |
| 111 | + { 1, 1, 1 } |
111 | 112 | }; |
112 | | - var expected = new[,] |
| 113 | + int[,] expected = |
113 | 114 | { |
114 | | - { 1, 0, 1 }, |
115 | | - { 0, 0, 0 }, |
116 | | - { 1, 0, 1 } |
| 115 | + { 1, 0, 1 }, |
| 116 | + { 0, 0, 0 }, |
| 117 | + { 1, 0, 1 } |
117 | 118 | }; |
118 | 119 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
119 | 120 | } |
120 | 121 |
|
121 | 122 | [Fact(Skip = "Remove this Skip property to run this test")] |
122 | 123 | public void Bigger_matrix() |
123 | 124 | { |
124 | | - var matrix = new[,] |
| 125 | + int[,] matrix = |
125 | 126 | { |
126 | | - { 1, 1, 0, 1, 1, 0, 0, 0 }, |
127 | | - { 1, 0, 1, 1, 0, 0, 0, 0 }, |
128 | | - { 1, 1, 1, 0, 0, 1, 1, 1 }, |
129 | | - { 0, 0, 0, 0, 0, 1, 1, 0 }, |
130 | | - { 1, 0, 0, 0, 1, 1, 0, 0 }, |
131 | | - { 1, 1, 0, 0, 0, 1, 1, 1 }, |
132 | | - { 0, 0, 1, 0, 1, 0, 0, 1 }, |
133 | | - { 1, 0, 0, 0, 0, 0, 1, 1 } |
| 127 | + { 1, 1, 0, 1, 1, 0, 0, 0 }, |
| 128 | + { 1, 0, 1, 1, 0, 0, 0, 0 }, |
| 129 | + { 1, 1, 1, 0, 0, 1, 1, 1 }, |
| 130 | + { 0, 0, 0, 0, 0, 1, 1, 0 }, |
| 131 | + { 1, 0, 0, 0, 1, 1, 0, 0 }, |
| 132 | + { 1, 1, 0, 0, 0, 1, 1, 1 }, |
| 133 | + { 0, 0, 1, 0, 1, 0, 0, 1 }, |
| 134 | + { 1, 0, 0, 0, 0, 0, 1, 1 } |
134 | 135 | }; |
135 | | - var expected = new[,] |
| 136 | + int[,] expected = |
136 | 137 | { |
137 | | - { 1, 1, 0, 1, 1, 0, 0, 0 }, |
138 | | - { 0, 0, 0, 0, 0, 1, 1, 0 }, |
139 | | - { 1, 0, 1, 1, 1, 1, 0, 1 }, |
140 | | - { 1, 0, 0, 0, 0, 0, 0, 1 }, |
141 | | - { 1, 1, 0, 0, 1, 0, 0, 1 }, |
142 | | - { 1, 1, 0, 1, 0, 0, 0, 1 }, |
143 | | - { 1, 0, 0, 0, 0, 0, 0, 0 }, |
144 | | - { 0, 0, 0, 0, 0, 0, 1, 1 } |
| 138 | + { 1, 1, 0, 1, 1, 0, 0, 0 }, |
| 139 | + { 0, 0, 0, 0, 0, 1, 1, 0 }, |
| 140 | + { 1, 0, 1, 1, 1, 1, 0, 1 }, |
| 141 | + { 1, 0, 0, 0, 0, 0, 0, 1 }, |
| 142 | + { 1, 1, 0, 0, 1, 0, 0, 1 }, |
| 143 | + { 1, 1, 0, 1, 0, 0, 0, 1 }, |
| 144 | + { 1, 0, 0, 0, 0, 0, 0, 0 }, |
| 145 | + { 0, 0, 0, 0, 0, 0, 1, 1 } |
145 | 146 | }; |
146 | 147 | Assert.Equal(expected, GameOfLife.Tick(matrix)); |
147 | 148 | } |
|
0 commit comments