Skip to content

Commit 588d798

Browse files
word-search: add generator
1 parent 29d6fa9 commit 588d798

File tree

2 files changed

+154
-250
lines changed

2 files changed

+154
-250
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{ func tuple
2+
ret $"({$0.column}, {$0.row})"
3+
end }}
4+
using Xunit;
5+
6+
public class {{ testClass }}
7+
{
8+
{{- for test in tests }}
9+
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
10+
public void {{ test.testMethod }}()
11+
{
12+
string[] wordsToSearchFor = {{ test.input.wordsToSearchFor }};
13+
var grid =
14+
{{- for line in test.input.grid }}
15+
{{ if for.last -}}
16+
{{ line | string.literal -}};
17+
{{- else -}}
18+
{{ line | string.append "\n" | string.literal }} +
19+
{{- end -}}
20+
{{- end }}
21+
var sut = new {{ testedClass }}(grid);
22+
var actual = sut.Search(wordsToSearchFor);
23+
{{- for key in test.expected | object.keys }}
24+
{{- if test.expected[key] }}
25+
Assert.Equal(({{ test.expected[key].start | tuple }}, {{ test.expected[key].end | tuple }}), actual[{{ key | string.literal }}]);
26+
{{- else }}
27+
Assert.Null(actual[{{ key | string.literal }}]);
28+
{{ end -}}
29+
{{ end -}}
30+
}
31+
{{ end -}}
32+
}

0 commit comments

Comments
 (0)