Skip to content

Commit 1593833

Browse files
Add value for test class
1 parent d7ceef1 commit 1593833

File tree

35 files changed

+114
-104
lines changed

35 files changed

+114
-104
lines changed

bin/add-practice-exercise.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ $generator = "${exerciseDir}/.meta/Generator.tpl"
5151
Add-Content -Path $generator -Value @"
5252
using Xunit;
5353
54-
public class ${exerciseName}Tests
54+
public class {{testClass}}
5555
{
56-
{{#test_cases}}
57-
[Fact{{#unless @first}}(Skip = "Remove this Skip property to run this test"){{/unless}}]
58-
public void {{test_method_name}}()
56+
{{for test in tests}}
57+
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
58+
public void {{test.testMethod}}()
5959
{
6060
// TODO: implement the test
6161
}
62-
{{/test_cases}}
62+
{{end}}
6363
}
6464
"@
6565
& dotnet run --project generators --exercise $Exercise
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class AcronymTests
3+
public class {{testClass}}
44
{
55
{{for test in tests}}
66
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7-
public void {{test.methodName}}()
7+
public void {{test.testMethod}}()
88
{
9-
Assert.Equal({{test.expected | string.literal}}, Acronym.Abbreviate({{test.input.phrase | string.literal}}));
9+
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
1010
}
1111
{{end}}
1212
}

exercises/practice/affine-cipher/.meta/Generator.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
using System;
22
using Xunit;
33

4-
public class AffineCipherTests
4+
public class {{testClass}}
55
{
66
{{for test in tests}}
77
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
8-
public void {{test.shortMethodName}}()
8+
public void {{test.shortTestMethod}}()
99
{
1010
{{if test.expected.error}}
11-
Assert.Throws<ArgumentException>(() => AffineCipher.{{test.property | string.capitalize}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
11+
Assert.Throws<ArgumentException>(() => AffineCipher.{{test.testedMethod}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
1212
{{else}}
13-
Assert.Equal({{test.expected | string.literal}}, AffineCipher.{{test.property | string.capitalize}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
13+
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}, {{test.input.key.a}}, {{test.input.key.b}}));
1414
{{end}}
1515
}
1616
{{end}}

exercises/practice/all-your-base/.meta/Generator.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
using System;
22
using Xunit;
33

4-
public class AllYourBaseTests
4+
public class {{testClass}}
55
{
66
{{for test in tests}}
77
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
8-
public void {{test.methodName}}()
8+
public void {{test.testMethod}}()
99
{
1010
{{if test.expected.error}}
1111
int[] digits = {{test.input.digits}};
1212
Assert.Throws<ArgumentException>(() => AllYourBase.Rebase({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
1313
{{else}}
1414
int[] digits = {{test.input.digits}};
1515
int[] expected = {{test.expected}};
16-
Assert.Equal(expected, AllYourBase.Rebase({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
16+
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.inputBase}}, digits, {{test.input.outputBase}}));
1717
{{end}}
1818
}
1919
{{end}}

exercises/practice/allergies/.meta/Generator.tpl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
using Xunit;
22

3-
public class AllergiesTests
3+
public class {{testClass}}
44
{
55
{{for test in tests | property "allergicTo" }}
66
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7-
public void {{test.methodName}}()
7+
public void {{test.testMethod}}()
88
{
9-
var sut = new Allergies({{test.input.score}});
9+
var sut = new {{testedClass}}({{test.input.score}});
1010
Assert.{{test.expected ? "True" : "False"}}(sut.IsAllergicTo({{test.input.item | enum "Allergen"}}));
1111
}
1212
{{end}}
1313

1414
{{for test in tests | property "list"}}
1515
[Fact(Skip = "Remove this Skip property to run this test")]
16-
public void {{test.methodName}}()
16+
public void {{test.testMethod}}()
1717
{
18-
var sut = new Allergies({{test.input.score}});
18+
var sut = new {{testedClass}}({{test.input.score}});
1919
{{if test.expected.empty?}}
2020
Assert.Empty(sut.List());
2121
{{else}}

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

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

5-
public class AlphameticsTests
5+
public class {{testClass}}
66
{
77
{{for test in tests}}
88
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
9-
public void {{test.methodName}}()
9+
public void {{test.testMethod}}()
1010
{
1111
{{if test.expected}}
1212
var actual = Alphametics.Solve({{test.input.puzzle | string.literal}});

exercises/practice/anagram/.meta/Generator.tpl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using Xunit;
22

3-
public class AnagramTests
3+
public class {{testClass}}
44
{
55
{{for test in tests}}
66
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7-
public void {{test.methodName}}()
7+
public void {{test.testMethod}}()
88
{
99
string[] candidates = {{test.input.candidates}};
10-
var sut = new Anagram({{test.input.subject | string.literal}});
10+
var sut = new {{testedClass}}({{test.input.subject | string.literal}});
1111
{{if test.expected.empty?}}
1212
Assert.Empty(sut.FindAnagrams(candidates));
1313
{{else}}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class ArmstrongNumbersTests
3+
public class {{testClass}}
44
{
55
{{for test in tests}}
66
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7-
public void {{test.methodName}}()
7+
public void {{test.testMethod}}()
88
{
9-
Assert.{{test.expected ? "True" : "False"}}(ArmstrongNumbers.IsArmstrongNumber({{test.input.number}}));
9+
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.{{test.testedMethod}}({{test.input.number}}));
1010
}
1111
{{end}}
1212
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class AtbashCipherTests
3+
public class {{testClass}}
44
{
55
{{for test in tests}}
66
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7-
public void {{test.shortMethodName}}()
7+
public void {{test.shortTestMethod}}()
88
{
9-
Assert.Equal({{test.expected | string.literal}}, AtbashCipher.{{test.property | string.capitalize}}({{test.input.phrase | string.literal}}));
9+
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
1010
}
1111
{{end}}
1212
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
using Xunit;
22

3-
public class DartsTests
3+
public class {{testClass}}
44
{
55
{{for test in tests}}
66
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
7-
public void {{test.methodName}}()
7+
public void {{test.testMethod}}()
88
{
9-
Assert.Equal({{test.expected}}, Darts.Score({{test.input.x}}, {{test.input.y}}));
9+
Assert.Equal({{test.expected}}, {{testedClass}}.{{test.testedMethod}}({{test.input.x}}, {{test.input.y}}));
1010
}
1111
{{end}}
1212
}

0 commit comments

Comments
 (0)