Skip to content

Commit 4ca1eb3

Browse files
Allow greater control over output (#2368)
* Update formatter * Allow greater control over output [no important files changed]
1 parent 9b55351 commit 4ca1eb3

File tree

63 files changed

+592
-555
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+592
-555
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.phrase | string.literal}}));
9+
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}));
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.shortTestMethod}}()
6+
{{- for test in tests }}
7+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
8+
public void {{ test.shortTestMethod }}()
99
{
10-
{{if test.expected.error}}
11-
Assert.Throws<ArgumentException>(() => AffineCipher.{{test.testedMethod}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
12-
{{else}}
13-
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
14-
{{end}}
10+
{{- if test.expected.error }}
11+
Assert.Throws<ArgumentException>(() => AffineCipher.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}, {{ test.input.key.a }}, {{ test.input.key.b }}));
12+
{{ else }}
13+
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}, {{ test.input.key.a }}, {{ test.input.key.b }}));
14+
{{ end -}}
1515
}
16-
{{end}}
16+
{{ end -}}
1717
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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-
int[] digits = {{test.input.digits}};
12-
Assert.Throws<ArgumentException>(() => AllYourBase.Rebase({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
13-
{{else}}
14-
int[] digits = {{test.input.digits}};
15-
int[] expected = {{test.expected}};
16-
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
17-
{{end}}
10+
{{- if test.expected.error }}
11+
int[] digits = {{ test.input.digits }};
12+
Assert.Throws<ArgumentException>(() => AllYourBase.Rebase({{ test.input.inputBase }}, digits, {{ test.input.outputBase }}));
13+
{{ else }}
14+
int[] digits = {{ test.input.digits }};
15+
int[] expected = {{ test.expected }};
16+
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.inputBase }}, digits, {{ test.input.outputBase }}));
17+
{{ end -}}
1818
}
19-
{{end}}
19+
{{ end -}}
2020
}
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
using Xunit;
22

3-
public class {{testClass}}
3+
public class {{ testClass }}
44
{
5-
{{for test in tests | property "allergicTo" }}
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 | property "allergicTo" }}
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 {{testedClass}}({{test.input.score}});
10-
Assert.{{test.expected ? "True" : "False"}}(sut.IsAllergicTo({{test.input.item | enum "Allergen"}}));
9+
var sut = new {{ testedClass }}({{ test.input.score }});
10+
Assert.{{ test.expected ? "True" : "False" }}(sut.IsAllergicTo({{ test.input.item | enum "Allergen" }}));
1111
}
12-
{{end}}
12+
{{ end }}
1313

14-
{{for test in tests | property "list"}}
14+
{{- for test in tests | property "list"}}
1515
[Fact(Skip = "Remove this Skip property to run this test")]
16-
public void {{test.testMethod}}()
16+
public void {{ test.testMethod }}()
1717
{
18-
var sut = new {{testedClass}}({{test.input.score}});
19-
{{if test.expected.empty?}}
18+
var sut = new {{ testedClass }}({{ test.input.score }});
19+
{{- if test.expected.empty? }}
2020
Assert.Empty(sut.List());
21-
{{else}}
21+
{{ else }}
2222
Allergen[] expected = [
23-
{{for expected in test.expected}}
24-
{{expected | enum "Allergen"}}{{if !for.last}},{{end}}
25-
{{end}}
23+
{{- for expected in test.expected }}
24+
{{ expected | enum "Allergen" }}{{- if !for.last }},{{ end -}}
25+
{{ end }}
2626
];
2727
Assert.Equal(expected, sut.List());
28-
{{end}}
28+
{{ end -}}
2929
}
30-
{{end}}
30+
{{ end }}
3131
}

exercises/practice/allergies/AllergiesTests.cs

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,71 +293,109 @@ public void List_when_no_allergies()
293293
public void List_when_just_eggs()
294294
{
295295
var sut = new Allergies(1);
296-
Allergen[] expected = [Allergen.Eggs];
296+
Allergen[] expected = [
297+
Allergen.Eggs
298+
];
297299
Assert.Equal(expected, sut.List());
298300
}
299301

300302
[Fact(Skip = "Remove this Skip property to run this test")]
301303
public void List_when_just_peanuts()
302304
{
303305
var sut = new Allergies(2);
304-
Allergen[] expected = [Allergen.Peanuts];
306+
Allergen[] expected = [
307+
Allergen.Peanuts
308+
];
305309
Assert.Equal(expected, sut.List());
306310
}
307311

308312
[Fact(Skip = "Remove this Skip property to run this test")]
309313
public void List_when_just_strawberries()
310314
{
311315
var sut = new Allergies(8);
312-
Allergen[] expected = [Allergen.Strawberries];
316+
Allergen[] expected = [
317+
Allergen.Strawberries
318+
];
313319
Assert.Equal(expected, sut.List());
314320
}
315321

316322
[Fact(Skip = "Remove this Skip property to run this test")]
317323
public void List_when_eggs_and_peanuts()
318324
{
319325
var sut = new Allergies(3);
320-
Allergen[] expected = [Allergen.Eggs, Allergen.Peanuts];
326+
Allergen[] expected = [
327+
Allergen.Eggs,
328+
Allergen.Peanuts
329+
];
321330
Assert.Equal(expected, sut.List());
322331
}
323332

324333
[Fact(Skip = "Remove this Skip property to run this test")]
325334
public void List_when_more_than_eggs_but_not_peanuts()
326335
{
327336
var sut = new Allergies(5);
328-
Allergen[] expected = [Allergen.Eggs, Allergen.Shellfish];
337+
Allergen[] expected = [
338+
Allergen.Eggs,
339+
Allergen.Shellfish
340+
];
329341
Assert.Equal(expected, sut.List());
330342
}
331343

332344
[Fact(Skip = "Remove this Skip property to run this test")]
333345
public void List_when_lots_of_stuff()
334346
{
335347
var sut = new Allergies(248);
336-
Allergen[] expected = [Allergen.Strawberries, Allergen.Tomatoes, Allergen.Chocolate, Allergen.Pollen, Allergen.Cats];
348+
Allergen[] expected = [
349+
Allergen.Strawberries,
350+
Allergen.Tomatoes,
351+
Allergen.Chocolate,
352+
Allergen.Pollen,
353+
Allergen.Cats
354+
];
337355
Assert.Equal(expected, sut.List());
338356
}
339357

340358
[Fact(Skip = "Remove this Skip property to run this test")]
341359
public void List_when_everything()
342360
{
343361
var sut = new Allergies(255);
344-
Allergen[] expected = [Allergen.Eggs, Allergen.Peanuts, Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes, Allergen.Chocolate, Allergen.Pollen, Allergen.Cats];
362+
Allergen[] expected = [
363+
Allergen.Eggs,
364+
Allergen.Peanuts,
365+
Allergen.Shellfish,
366+
Allergen.Strawberries,
367+
Allergen.Tomatoes,
368+
Allergen.Chocolate,
369+
Allergen.Pollen,
370+
Allergen.Cats
371+
];
345372
Assert.Equal(expected, sut.List());
346373
}
347374

348375
[Fact(Skip = "Remove this Skip property to run this test")]
349376
public void List_when_no_allergen_score_parts()
350377
{
351378
var sut = new Allergies(509);
352-
Allergen[] expected = [Allergen.Eggs, Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes, Allergen.Chocolate, Allergen.Pollen, Allergen.Cats];
379+
Allergen[] expected = [
380+
Allergen.Eggs,
381+
Allergen.Shellfish,
382+
Allergen.Strawberries,
383+
Allergen.Tomatoes,
384+
Allergen.Chocolate,
385+
Allergen.Pollen,
386+
Allergen.Cats
387+
];
353388
Assert.Equal(expected, sut.List());
354389
}
355390

356391
[Fact(Skip = "Remove this Skip property to run this test")]
357392
public void List_when_no_allergen_score_parts_without_highest_valid_score()
358393
{
359394
var sut = new Allergies(257);
360-
Allergen[] expected = [Allergen.Eggs];
395+
Allergen[] expected = [
396+
Allergen.Eggs
397+
];
361398
Assert.Equal(expected, sut.List());
362399
}
400+
363401
}

exercises/practice/alphametics/.meta/Generator.tpl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@ using System;
22
using System.Collections.Generic;
33
using Xunit;
44

5-
public class {{testClass}}
5+
public class {{ testClass }}
66
{
7-
{{for test in tests}}
8-
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
9-
public void {{test.testMethod}}()
7+
{{- for test in tests }}
8+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
9+
public void {{ test.testMethod }}()
1010
{
11-
{{if test.expected}}
12-
var actual = Alphametics.Solve({{test.input.puzzle | string.literal}});
11+
{{- if test.expected }}
12+
var actual = Alphametics.Solve({{ test.input.puzzle | string.literal }});
1313
var expected = new Dictionary<char, int>
1414
{
15-
{{for key in test.expected | object.keys}}
16-
['{{key}}'] = {{test.expected[key]}}{{if !for.last}},{{end}}
17-
{{end}}
15+
{{- for key in test.expected | object.keys }}
16+
['{{ key }}'] = {{ test.expected[key] }}{{- if !for.last }},{{ end -}}
17+
{{ end -}}
1818
};
19-
Assert.Equal(expected, actual);
20-
{{else}}
21-
Assert.Throws<ArgumentException>(() => Alphametics.Solve({{test.input.puzzle | string.literal}}));
22-
{{end}}
19+
Assert.Equal(expected, actual);
20+
{{ else }}
21+
Assert.Throws<ArgumentException>(() => Alphametics.Solve({{ test.input.puzzle | string.literal }}));
22+
{{ end -}}
2323
}
24-
{{end}}
24+
{{ end -}}
2525
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
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[] candidates = {{test.input.candidates}};
10-
var sut = new {{testedClass}}({{test.input.subject | string.literal}});
11-
{{if test.expected.empty?}}
9+
string[] candidates = {{ test.input.candidates }};
10+
var sut = new {{ testedClass }}({{ test.input.subject | string.literal }});
11+
{{- if test.expected.empty? }}
1212
Assert.Empty(sut.FindAnagrams(candidates));
13-
{{else}}
14-
string[] expected = {{test.expected}};
13+
{{ else }}
14+
string[] expected = {{ test.expected }};
1515
Assert.Equal(expected, sut.FindAnagrams(candidates));
16-
{{end}}
16+
{{ end -}}
1717
}
18-
{{end}}
18+
{{ end -}}
1919
}
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.number}}));
9+
Assert.{{ test.expected ? "True" : "False" }}({{ testedClass }}.{{ test.testedMethod }}({{ test.input.number }}));
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.shortTestMethod}}()
5+
{{- for test in tests }}
6+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
7+
public void {{ test.shortTestMethod }}()
88
{
9-
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
9+
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.phrase | 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 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-
Assert.Equal({{if test.expected.error}}-1{{else}}{{test.expected}}{{end}}, {{testedClass}}.{{test.testedMethod}}({{test.input.array}}, {{test.input.value}}));
10+
Assert.Equal({{- if test.expected.error }}-1{{ else }}{{ test.expected }}{{ end }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.array }}, {{ test.input.value }}));
1111
}
12-
{{end}}
12+
{{ end -}}
1313
}

0 commit comments

Comments
 (0)