Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions exercises/practice/acronym/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}));
}
{{end}}
{{ end -}}
}
20 changes: 10 additions & 10 deletions exercises/practice/affine-cipher/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using Xunit;

public class {{testClass}}
public class {{ testClass }}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.shortTestMethod}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.shortTestMethod }}()
{
{{if test.expected.error}}
Assert.Throws<ArgumentException>(() => AffineCipher.{{test.testedMethod}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
{{else}}
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
{{end}}
{{- if test.expected.error }}
Assert.Throws<ArgumentException>(() => AffineCipher.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}, {{ test.input.key.a }}, {{ test.input.key.b }}));
{{ else }}
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}, {{ test.input.key.a }}, {{ test.input.key.b }}));
{{ end -}}
}
{{end}}
{{ end -}}
}
26 changes: 13 additions & 13 deletions exercises/practice/all-your-base/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using System;
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
{{if test.expected.error}}
int[] digits = {{test.input.digits}};
Assert.Throws<ArgumentException>(() => AllYourBase.Rebase({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
{{else}}
int[] digits = {{test.input.digits}};
int[] expected = {{test.expected}};
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
{{end}}
{{- if test.expected.error }}
int[] digits = {{ test.input.digits }};
Assert.Throws<ArgumentException>(() => AllYourBase.Rebase({{ test.input.inputBase }}, digits, {{ test.input.outputBase }}));
{{ else }}
int[] digits = {{ test.input.digits }};
int[] expected = {{ test.expected }};
Assert.Equal(expected, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.inputBase }}, digits, {{ test.input.outputBase }}));
{{ end -}}
}
{{end}}
{{ end -}}
}
34 changes: 17 additions & 17 deletions exercises/practice/allergies/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
using Xunit;

public class {{testClass}}
public class {{ testClass }}
{
{{for test in tests | property "allergicTo" }}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.testMethod}}()
{{- for test in tests | property "allergicTo" }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
var sut = new {{testedClass}}({{test.input.score}});
Assert.{{test.expected ? "True" : "False"}}(sut.IsAllergicTo({{test.input.item | enum "Allergen"}}));
var sut = new {{ testedClass }}({{ test.input.score }});
Assert.{{ test.expected ? "True" : "False" }}(sut.IsAllergicTo({{ test.input.item | enum "Allergen" }}));
}
{{end}}
{{ end }}

{{for test in tests | property "list"}}
{{- for test in tests | property "list"}}
[Fact(Skip = "Remove this Skip property to run this test")]
public void {{test.testMethod}}()
public void {{ test.testMethod }}()
{
var sut = new {{testedClass}}({{test.input.score}});
{{if test.expected.empty?}}
var sut = new {{ testedClass }}({{ test.input.score }});
{{- if test.expected.empty? }}
Assert.Empty(sut.List());
{{else}}
{{ else }}
Allergen[] expected = [
{{for expected in test.expected}}
{{expected | enum "Allergen"}}{{if !for.last}},{{end}}
{{end}}
{{- for expected in test.expected }}
{{ expected | enum "Allergen" }}{{- if !for.last }},{{ end -}}
{{ end }}
];
Assert.Equal(expected, sut.List());
{{end}}
{{ end -}}
}
{{end}}
{{ end }}
}
56 changes: 47 additions & 9 deletions exercises/practice/allergies/AllergiesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,71 +293,109 @@ public void List_when_no_allergies()
public void List_when_just_eggs()
{
var sut = new Allergies(1);
Allergen[] expected = [Allergen.Eggs];
Allergen[] expected = [
Allergen.Eggs
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_just_peanuts()
{
var sut = new Allergies(2);
Allergen[] expected = [Allergen.Peanuts];
Allergen[] expected = [
Allergen.Peanuts
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_just_strawberries()
{
var sut = new Allergies(8);
Allergen[] expected = [Allergen.Strawberries];
Allergen[] expected = [
Allergen.Strawberries
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_eggs_and_peanuts()
{
var sut = new Allergies(3);
Allergen[] expected = [Allergen.Eggs, Allergen.Peanuts];
Allergen[] expected = [
Allergen.Eggs,
Allergen.Peanuts
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_more_than_eggs_but_not_peanuts()
{
var sut = new Allergies(5);
Allergen[] expected = [Allergen.Eggs, Allergen.Shellfish];
Allergen[] expected = [
Allergen.Eggs,
Allergen.Shellfish
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_lots_of_stuff()
{
var sut = new Allergies(248);
Allergen[] expected = [Allergen.Strawberries, Allergen.Tomatoes, Allergen.Chocolate, Allergen.Pollen, Allergen.Cats];
Allergen[] expected = [
Allergen.Strawberries,
Allergen.Tomatoes,
Allergen.Chocolate,
Allergen.Pollen,
Allergen.Cats
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_everything()
{
var sut = new Allergies(255);
Allergen[] expected = [Allergen.Eggs, Allergen.Peanuts, Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes, Allergen.Chocolate, Allergen.Pollen, Allergen.Cats];
Allergen[] expected = [
Allergen.Eggs,
Allergen.Peanuts,
Allergen.Shellfish,
Allergen.Strawberries,
Allergen.Tomatoes,
Allergen.Chocolate,
Allergen.Pollen,
Allergen.Cats
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_no_allergen_score_parts()
{
var sut = new Allergies(509);
Allergen[] expected = [Allergen.Eggs, Allergen.Shellfish, Allergen.Strawberries, Allergen.Tomatoes, Allergen.Chocolate, Allergen.Pollen, Allergen.Cats];
Allergen[] expected = [
Allergen.Eggs,
Allergen.Shellfish,
Allergen.Strawberries,
Allergen.Tomatoes,
Allergen.Chocolate,
Allergen.Pollen,
Allergen.Cats
];
Assert.Equal(expected, sut.List());
}

[Fact(Skip = "Remove this Skip property to run this test")]
public void List_when_no_allergen_score_parts_without_highest_valid_score()
{
var sut = new Allergies(257);
Allergen[] expected = [Allergen.Eggs];
Allergen[] expected = [
Allergen.Eggs
];
Assert.Equal(expected, sut.List());
}

}
28 changes: 14 additions & 14 deletions exercises/practice/alphametics/.meta/Generator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@ using System;
using System.Collections.Generic;
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
{{if test.expected}}
var actual = Alphametics.Solve({{test.input.puzzle | string.literal}});
{{- if test.expected }}
var actual = Alphametics.Solve({{ test.input.puzzle | string.literal }});
var expected = new Dictionary<char, int>
{
{{for key in test.expected | object.keys}}
['{{key}}'] = {{test.expected[key]}}{{if !for.last}},{{end}}
{{end}}
{{- for key in test.expected | object.keys }}
['{{ key }}'] = {{ test.expected[key] }}{{- if !for.last }},{{ end -}}
{{ end -}}
};
Assert.Equal(expected, actual);
{{else}}
Assert.Throws<ArgumentException>(() => Alphametics.Solve({{test.input.puzzle | string.literal}}));
{{end}}
Assert.Equal(expected, actual);
{{ else }}
Assert.Throws<ArgumentException>(() => Alphametics.Solve({{ test.input.puzzle | string.literal }}));
{{ end -}}
}
{{end}}
{{ end -}}
}
22 changes: 11 additions & 11 deletions exercises/practice/anagram/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
string[] candidates = {{test.input.candidates}};
var sut = new {{testedClass}}({{test.input.subject | string.literal}});
{{if test.expected.empty?}}
string[] candidates = {{ test.input.candidates }};
var sut = new {{ testedClass }}({{ test.input.subject | string.literal }});
{{- if test.expected.empty? }}
Assert.Empty(sut.FindAnagrams(candidates));
{{else}}
string[] expected = {{test.expected}};
{{ else }}
string[] expected = {{ test.expected }};
Assert.Equal(expected, sut.FindAnagrams(candidates));
{{end}}
{{ end -}}
}
{{end}}
{{ end -}}
}
12 changes: 6 additions & 6 deletions exercises/practice/armstrong-numbers/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.{{test.testedMethod}}({{test.input.number}}));
Assert.{{ test.expected ? "True" : "False" }}({{ testedClass }}.{{ test.testedMethod }}({{ test.input.number }}));
}
{{end}}
{{ end -}}
}
12 changes: 6 additions & 6 deletions exercises/practice/atbash-cipher/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

public class {{testClass}}
public class {{ testClass }}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.shortTestMethod}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.shortTestMethod }}()
{
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
Assert.Equal({{ test.expected | string.literal }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.phrase | string.literal }}));
}
{{end}}
{{ end -}}
}
12 changes: 6 additions & 6 deletions exercises/practice/binary-search/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using System;
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
Assert.Equal({{if test.expected.error}}-1{{else}}{{test.expected}}{{end}}, {{testedClass}}.{{test.testedMethod}}({{test.input.array}}, {{test.input.value}}));
Assert.Equal({{- if test.expected.error }}-1{{ else }}{{ test.expected }}{{ end }}, {{ testedClass }}.{{ test.testedMethod }}({{ test.input.array }}, {{ test.input.value }}));
}
{{end}}
{{ end -}}
}
12 changes: 6 additions & 6 deletions exercises/practice/binary/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

public class {{testClass}}
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}}()
{{- for test in tests }}
[Fact{{ if !for.first }}(Skip = "Remove this Skip property to run this test"){{ end }}]
public void {{ test.testMethod }}()
{
Assert.Equal({{if test.expected}}{{test.expected}}{{else}}0{{end}}, {{testedClass}}.To{{test.testedMethod}}({{test.input.binary | string.literal}}));
Assert.Equal({{ if test.expected }}{{ test.expected }}{{ else }}0{{ end }}, {{ testedClass }}.To{{ test.testedMethod }}({{ test.input.binary | string.literal }}));
}
{{end}}
{{ end -}}
}
Loading
Loading