Skip to content

Commit ed043b0

Browse files
Fix
1 parent c515d81 commit ed043b0

File tree

11 files changed

+122
-80
lines changed

11 files changed

+122
-80
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
9-
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.plaintext | string.literal}}));
9+
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.plaintext | string.literal }}));
1010
}
11-
{{end}}
11+
{{ end -}}
1212
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
9-
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.{{test.testedMethod}}([{{for pair in test.input.dominoes}}({{pair[0]}}, {{pair[1]}}){{if !for.last}}, {{end}}{{end}}]));
9+
Assert.{{ test.expected ? "True" : "False" }}({{ testedClass }}.{{ test.testedMethod }}([{{for pair in test.input.dominoes}}({{ pair[0] }}, {{ pair[1] }}){{ if !for.last}}, {{ end }}{{ end }}]));
1010
}
11-
{{end}}
11+
{{ end -}}
1212
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
using System;
22
using Xunit;
33

4-
public class {{testClass}}
4+
public class {{ testClass }}
55
{
6-
{{for test in tests}}
7-
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
8-
public void {{test.testMethod}}()
6+
{{- for test in tests }}
7+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
8+
public void {{ test.testMethod }}()
99
{
10-
{{if test.expected.error}}
11-
Assert.Throws<InvalidOperationException>(() => {{testedClass}}.{{test.testedMethod}}({{test.input.instructions}}));
12-
{{else}}
13-
Assert.Equal("{{test.expected | array.join " "}}", {{testedClass}}.{{test.testedMethod}}({{test.input.instructions}}));
14-
{{end}}
10+
{{- if test.expected.error }}
11+
Assert.Throws<InvalidOperationException>(() => {{ testedClass }}.{{ test.testedMethod }}({{ test.input.instructions }}));
12+
{{ else }}
13+
Assert.Equal("{{test.expected | array.join " "}}", {{ testedClass }}.{{ test.testedMethod }}({{ test.input.instructions }}));
14+
{{ end -}}
1515
}
16-
{{end}}
16+
{{ end -}}
1717
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
using System;
2-
using Xunit;
3-
41
{{func datetime
52
d = date.parse $0
63
if d.hour + d.minute + d.second == 0
@@ -10,13 +7,16 @@ using Xunit;
107
end
118
end}}
129

13-
public class {{testClass}}
10+
using System;
11+
using Xunit;
12+
13+
public class {{ testClass }}
1414
{
15-
{{for test in tests}}
16-
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
17-
public void {{test.testMethod}}()
15+
{{- for test in tests }}
16+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
17+
public void {{ test.testMethod }}()
1818
{
19-
Assert.Equal({{test.expected | datetime}}, {{testedClass}}.{{test.testedMethod}}({{test.input.moment | datetime}}));
19+
Assert.Equal({{test.expected | datetime}}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.moment | datetime }}));
2020
}
21-
{{end}}
21+
{{ end -}}
2222
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
9-
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.{{test.testedMethod}}({{test.input.isbn | string.literal}}));
9+
Assert.{{ test.expected ? "True" : "False" }}({{ testedClass }}.{{ test.testedMethod }}({{ test.input.isbn | string.literal }}));
1010
}
11-
{{end}}
11+
{{ end -}}
1212
}
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
99
(int weight, int value)[] items = [{{for item in test.input.items}}(weight: {{item.weight}}, value: {{item.value}}){{if !for.last}}, {{end}}{{end}}];
10-
Assert.Equal({{test.expected}}, {{testedClass}}.{{test.testedMethod}}({{test.input.maximumWeight}}, items));
10+
Assert.Equal({{ test.expected }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.maximumWeight }}, items));
1111
}
12-
{{end}}
12+
{{ end -}}
1313
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
9-
var sut = new Meetup({{test.input.month}}, {{test.input.year}});
9+
var sut = new Meetup({{ test.input.month }}, {{ test.input.year }});
1010
var expected = new DateTime({{test.expected | string.replace "-0" "-" | string.replace "-" ", "}});
11-
Assert.Equal(expected, sut.Day({{test.input.dayofweek | enum "DayOfWeek"}}, {{test.input.week | enum "Schedule"}}));
11+
Assert.Equal(expected, sut.Day({{ test.input.dayofweek | enum "DayOfWeek" }}, {{ test.input.week | enum "Schedule" }}));
1212
}
13-
{{end}}
13+
{{ end -}}
1414
}
Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
9-
{{if test.expected.empty?}}
10-
Assert.Empty({{testedClass}}.Calculate({{test.input.count}}));
11-
{{else}}
12-
int[][] expected = {{test.expected}};
13-
Assert.Equal(expected, {{testedClass}}.Calculate({{test.input.count}}));
14-
{{end}}
9+
{{- if test.expected.empty? }}
10+
Assert.Empty({{ testedClass }}.Calculate({{ test.input.count }}));
11+
{{ else }}
12+
int[][] expected = [
13+
{{- for row in test.expected }}
14+
{{ row }}{{- if !for.last }},{{ end -}}
15+
{{ end }}
16+
];
17+
Assert.Equal(expected, {{ testedClass }}.Calculate({{ test.input.count }}));
18+
{{ end -}}
1519
}
16-
{{end}}
20+
{{ end -}}
1721
}

exercises/practice/pascals-triangle/PascalsTriangleTests.cs

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,87 @@ public void Zero_rows()
1111
[Fact(Skip = "Remove this Skip property to run this test")]
1212
public void Single_row()
1313
{
14-
int[][] expected = [[1]];
14+
int[][] expected = [
15+
[1]
16+
];
1517
Assert.Equal(expected, PascalsTriangle.Calculate(1));
1618
}
1719

1820
[Fact(Skip = "Remove this Skip property to run this test")]
1921
public void Two_rows()
2022
{
21-
int[][] expected = [[1], [1, 1]];
23+
int[][] expected = [
24+
[1],
25+
[1, 1]
26+
];
2227
Assert.Equal(expected, PascalsTriangle.Calculate(2));
2328
}
2429

2530
[Fact(Skip = "Remove this Skip property to run this test")]
2631
public void Three_rows()
2732
{
28-
int[][] expected = [[1], [1, 1], [1, 2, 1]];
33+
int[][] expected = [
34+
[1],
35+
[1, 1],
36+
[1, 2, 1]
37+
];
2938
Assert.Equal(expected, PascalsTriangle.Calculate(3));
3039
}
3140

3241
[Fact(Skip = "Remove this Skip property to run this test")]
3342
public void Four_rows()
3443
{
35-
int[][] expected = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
44+
int[][] expected = [
45+
[1],
46+
[1, 1],
47+
[1, 2, 1],
48+
[1, 3, 3, 1]
49+
];
3650
Assert.Equal(expected, PascalsTriangle.Calculate(4));
3751
}
3852

3953
[Fact(Skip = "Remove this Skip property to run this test")]
4054
public void Five_rows()
4155
{
42-
int[][] expected = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]];
56+
int[][] expected = [
57+
[1],
58+
[1, 1],
59+
[1, 2, 1],
60+
[1, 3, 3, 1],
61+
[1, 4, 6, 4, 1]
62+
];
4363
Assert.Equal(expected, PascalsTriangle.Calculate(5));
4464
}
4565

4666
[Fact(Skip = "Remove this Skip property to run this test")]
4767
public void Six_rows()
4868
{
49-
int[][] expected = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1]];
69+
int[][] expected = [
70+
[1],
71+
[1, 1],
72+
[1, 2, 1],
73+
[1, 3, 3, 1],
74+
[1, 4, 6, 4, 1],
75+
[1, 5, 10, 10, 5, 1]
76+
];
5077
Assert.Equal(expected, PascalsTriangle.Calculate(6));
5178
}
5279

5380
[Fact(Skip = "Remove this Skip property to run this test")]
5481
public void Ten_rows()
5582
{
56-
int[][] expected = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1], [1, 7, 21, 35, 35, 21, 7, 1], [1, 8, 28, 56, 70, 56, 28, 8, 1], [1, 9, 36, 84, 126, 126, 84, 36, 9, 1]];
83+
int[][] expected = [
84+
[1],
85+
[1, 1],
86+
[1, 2, 1],
87+
[1, 3, 3, 1],
88+
[1, 4, 6, 4, 1],
89+
[1, 5, 10, 10, 5, 1],
90+
[1, 6, 15, 20, 15, 6, 1],
91+
[1, 7, 21, 35, 35, 21, 7, 1],
92+
[1, 8, 28, 56, 70, 56, 28, 8, 1],
93+
[1, 9, 36, 84, 126, 126, 84, 36, 9, 1]
94+
];
5795
Assert.Equal(expected, PascalsTriangle.Calculate(10));
5896
}
5997
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
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}}()
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 }}()
88
{
9-
string[] hands = {{test.input.hands}};
10-
string[] expected = {{test.expected}};
11-
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}(hands));
9+
string[] hands = {{ test.input.hands }};
10+
string[] expected = {{ test.expected }};
11+
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}(hands));
1212
}
13-
{{end}}
13+
{{ end -}}
1414
}

0 commit comments

Comments
 (0)