Skip to content

Commit feb5f14

Browse files
matrix: add generator
1 parent 8f48abb commit feb5f14

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Xunit;
2+
3+
public class {{testClass}}
4+
{
5+
{{for test in tests}}
6+
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7+
public void {{test.testMethod}}()
8+
{
9+
var sut = new Matrix({{test.input.string | string.literal}});
10+
int[] expected = {{test.expected}};
11+
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.index}}));
12+
}
13+
{{end}}
14+
}

exercises/practice/matrix/MatrixTests.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,63 @@ public class MatrixTests
66
public void Extract_row_from_one_number_matrix()
77
{
88
var sut = new Matrix("1");
9-
Assert.Equal(new[] { 1 }, sut.Row(1));
9+
int[] expected = [1];
10+
Assert.Equal(expected, Matrix.Row(1));
1011
}
1112

1213
[Fact(Skip = "Remove this Skip property to run this test")]
1314
public void Can_extract_row()
1415
{
1516
var sut = new Matrix("1 2\n3 4");
16-
Assert.Equal(new[] { 3, 4 }, sut.Row(2));
17+
int[] expected = [3, 4];
18+
Assert.Equal(expected, Matrix.Row(2));
1719
}
1820

1921
[Fact(Skip = "Remove this Skip property to run this test")]
2022
public void Extract_row_where_numbers_have_different_widths()
2123
{
2224
var sut = new Matrix("1 2\n10 20");
23-
Assert.Equal(new[] { 10, 20 }, sut.Row(2));
25+
int[] expected = [10, 20];
26+
Assert.Equal(expected, Matrix.Row(2));
2427
}
2528

2629
[Fact(Skip = "Remove this Skip property to run this test")]
2730
public void Can_extract_row_from_non_square_matrix_with_no_corresponding_column()
2831
{
2932
var sut = new Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6");
30-
Assert.Equal(new[] { 8, 7, 6 }, sut.Row(4));
33+
int[] expected = [8, 7, 6];
34+
Assert.Equal(expected, Matrix.Row(4));
3135
}
3236

3337
[Fact(Skip = "Remove this Skip property to run this test")]
3438
public void Extract_column_from_one_number_matrix()
3539
{
3640
var sut = new Matrix("1");
37-
Assert.Equal(new[] { 1 }, sut.Column(1));
41+
int[] expected = [1];
42+
Assert.Equal(expected, Matrix.Column(1));
3843
}
3944

4045
[Fact(Skip = "Remove this Skip property to run this test")]
4146
public void Can_extract_column()
4247
{
4348
var sut = new Matrix("1 2 3\n4 5 6\n7 8 9");
44-
Assert.Equal(new[] { 3, 6, 9 }, sut.Column(3));
49+
int[] expected = [3, 6, 9];
50+
Assert.Equal(expected, Matrix.Column(3));
4551
}
4652

4753
[Fact(Skip = "Remove this Skip property to run this test")]
4854
public void Can_extract_column_from_non_square_matrix_with_no_corresponding_row()
4955
{
5056
var sut = new Matrix("1 2 3 4\n5 6 7 8\n9 8 7 6");
51-
Assert.Equal(new[] { 4, 8, 6 }, sut.Column(4));
57+
int[] expected = [4, 8, 6];
58+
Assert.Equal(expected, Matrix.Column(4));
5259
}
5360

5461
[Fact(Skip = "Remove this Skip property to run this test")]
5562
public void Extract_column_where_numbers_have_different_widths()
5663
{
5764
var sut = new Matrix("89 1903 3\n18 3 1\n9 4 800");
58-
Assert.Equal(new[] { 1903, 3, 4 }, sut.Column(2));
65+
int[] expected = [1903, 3, 4];
66+
Assert.Equal(expected, Matrix.Column(2));
5967
}
6068
}

0 commit comments

Comments
 (0)