Skip to content

Commit

Permalink
word-search: add generator
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Feb 5, 2025
1 parent 29d6fa9 commit 588d798
Show file tree
Hide file tree
Showing 2 changed files with 154 additions and 250 deletions.
32 changes: 32 additions & 0 deletions exercises/practice/word-search/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{ func tuple
ret $"({$0.column}, {$0.row})"
end }}
using Xunit;

public class {{ testClass }}
{
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
string[] wordsToSearchFor = {{ test.input.wordsToSearchFor }};
var grid =
{{- for line in test.input.grid }}
{{ if for.last -}}
{{ line | string.literal -}};
{{- else -}}
{{ line | string.append "\n" | string.literal }} +
{{- end -}}
{{- end }}
var sut = new {{ testedClass }}(grid);
var actual = sut.Search(wordsToSearchFor);
{{- for key in test.expected | object.keys }}
{{- if test.expected[key] }}
Assert.Equal(({{ test.expected[key].start | tuple }}, {{ test.expected[key].end | tuple }}), actual[{{ key | string.literal }}]);
{{- else }}
Assert.Null(actual[{{ key | string.literal }}]);
{{ end -}}
{{ end -}}
}
{{ end -}}
}
Loading

0 comments on commit 588d798

Please sign in to comment.