Skip to content

Commit

Permalink
Add value for test class
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSchierboom committed Feb 3, 2025
1 parent d7ceef1 commit 1593833
Show file tree
Hide file tree
Showing 35 changed files with 114 additions and 104 deletions.
10 changes: 5 additions & 5 deletions bin/add-practice-exercise.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,15 @@ $generator = "${exerciseDir}/.meta/Generator.tpl"
Add-Content -Path $generator -Value @"
using Xunit;
public class ${exerciseName}Tests
public class {{testClass}}
{
{{#test_cases}}
[Fact{{#unless @first}}(Skip = "Remove this Skip property to run this test"){{/unless}}]
public void {{test_method_name}}()
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.testMethod}}()
{
// TODO: implement the test
}
{{/test_cases}}
{{end}}
}
"@
& dotnet run --project generators --exercise $Exercise
Expand Down
6 changes: 3 additions & 3 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 AcronymTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
Assert.Equal({{test.expected | string.literal}}, Acronym.Abbreviate({{test.input.phrase | string.literal}}));
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
}
{{end}}
}
8 changes: 4 additions & 4 deletions exercises/practice/affine-cipher/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Xunit;

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

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

public class AllergiesTests
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.methodName}}()
public void {{test.testMethod}}()
{
var sut = new Allergies({{test.input.score}});
var sut = new {{testedClass}}({{test.input.score}});
Assert.{{test.expected ? "True" : "False"}}(sut.IsAllergicTo({{test.input.item | enum "Allergen"}}));
}
{{end}}

{{for test in tests | property "list"}}
[Fact(Skip = "Remove this Skip property to run this test")]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
var sut = new Allergies({{test.input.score}});
var sut = new {{testedClass}}({{test.input.score}});
{{if test.expected.empty?}}
Assert.Empty(sut.List());
{{else}}
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/alphametics/.meta/Generator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ using System;
using System.Collections.Generic;
using Xunit;

public class AlphameticsTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
{{if test.expected}}
var actual = Alphametics.Solve({{test.input.puzzle | string.literal}});
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/anagram/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Xunit;

public class AnagramTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
string[] candidates = {{test.input.candidates}};
var sut = new Anagram({{test.input.subject | string.literal}});
var sut = new {{testedClass}}({{test.input.subject | string.literal}});
{{if test.expected.empty?}}
Assert.Empty(sut.FindAnagrams(candidates));
{{else}}
Expand Down
6 changes: 3 additions & 3 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 ArmstrongNumbersTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
Assert.{{test.expected ? "True" : "False"}}(ArmstrongNumbers.IsArmstrongNumber({{test.input.number}}));
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.{{test.testedMethod}}({{test.input.number}}));
}
{{end}}
}
6 changes: 3 additions & 3 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 AtbashCipherTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.shortMethodName}}()
public void {{test.shortTestMethod}}()
{
Assert.Equal({{test.expected | string.literal}}, AtbashCipher.{{test.property | string.capitalize}}({{test.input.phrase | string.literal}}));
Assert.Equal({{test.expected | string.literal}}, {{testedClass}}.{{test.testedMethod}}({{test.input.phrase | string.literal}}));
}
{{end}}
}
6 changes: 3 additions & 3 deletions exercises/practice/darts/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

public class DartsTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
Assert.Equal({{test.expected}}, Darts.Score({{test.input.x}}, {{test.input.y}}));
Assert.Equal({{test.expected}}, {{testedClass}}.{{test.testedMethod}}({{test.input.x}}, {{test.input.y}}));
}
{{end}}
}
6 changes: 3 additions & 3 deletions exercises/practice/difference-of-squares/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

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

public class EliudsEggsTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
Assert.Equal({{test.expected}}, EliudsEggs.EggCount({{test.input.number}}));
Assert.Equal({{test.expected}}, {{testedClass}}.{{test.testedMethod}}({{test.input.number}}));
}
{{end}}
}
6 changes: 3 additions & 3 deletions exercises/practice/hamming/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Xunit;

public class HammingTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
{{if test.expected.error}}
Assert.Throws<ArgumentException>(() => Hamming.Distance({{test.input.strand1 | string.literal}}, {{test.input.strand2 | string.literal}}));
{{else}}
Assert.Equal({{test.expected}}, Hamming.Distance({{test.input.strand1 | string.literal}}, {{test.input.strand2 | string.literal}}));
Assert.Equal({{test.expected}}, {{testedClass}}.{{test.testedMethod}}({{test.input.strand1 | string.literal}}, {{test.input.strand2 | string.literal}}));
{{end}}
}
{{end}}
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/isogram/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

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

public class LeapTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
Assert.{{test.expected ? "True" : "False"}}(Leap.IsLeapYear({{test.input.year}}));
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.Is{{test.testedMethod}}({{test.input.year}}));
}
{{end}}
}
6 changes: 3 additions & 3 deletions exercises/practice/pangram/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

public class PangramTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
Assert.{{test.expected ? "True" : "False"}}(Pangram.IsPangram({{test.input.sentence | string.literal}}));
Assert.{{test.expected ? "True" : "False"}}({{testedClass}}.{{test.testedMethod}}({{test.input.sentence | string.literal}}));
}
{{end}}
}
6 changes: 3 additions & 3 deletions exercises/practice/perfect-numbers/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
using System;
using Xunit;

public class PerfectNumbersTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.shortMethodName}}()
public void {{test.shortTestMethod}}()
{
{{if test.expected.error}}
Assert.Throws<ArgumentOutOfRangeException>(() => PerfectNumbers.Classify({{test.input.number}}));
{{else}}
Assert.Equal({{test.expected | enum "Classification"}}, PerfectNumbers.Classify({{test.input.number}}));
Assert.Equal({{test.expected | enum "Classification"}}, {{testedClass}}.{{test.testedMethod}}({{test.input.number}}));
{{end}}
}
{{end}}
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/rotational-cipher/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using Xunit;

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

public class SeriesTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
{{if test.expected.error}}
Assert.Throws<ArgumentException>(() => Series.Slices({{test.input.series | string.literal}}, {{test.input.sliceLength}}));
{{else}}
string[] expected = {{test.expected}};
Assert.Equal(expected, Series.Slices({{test.input.series | string.literal}}, {{test.input.sliceLength}}));
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.series | string.literal}}, {{test.input.sliceLength}}));
{{end}}
}
{{end}}
Expand Down
6 changes: 3 additions & 3 deletions exercises/practice/sieve/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
using Xunit;

public class SieveTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
int[] expected = {{test.expected}};
Assert.Equal(expected, Sieve.Primes({{test.input.limit}}));
Assert.Equal(expected, {{testedClass}}.{{test.testedMethod}}({{test.input.limit}}));
}
{{end}}
}
4 changes: 2 additions & 2 deletions exercises/practice/simple-cipher/.meta/Generator.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ using Xunit;
{{end}}
{{end}}

public class SimpleCipherTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
var sut = new SimpleCipher({{if test.input.key}}{{test.input.key | string.literal}}{{end}});
{{if test.property == "encode"}}
Expand Down
4 changes: 2 additions & 2 deletions exercises/practice/space-age/.meta/Generator.tpl
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using Xunit;

public class SpaceAgeTests
public class {{testClass}}
{
{{for test in tests}}
[Fact{{if !for.first}}(Skip = "Remove this Skip property to run this test"){{end}}]
public void {{test.methodName}}()
public void {{test.testMethod}}()
{
var sut = new SpaceAge({{test.input.seconds}});
Assert.Equal({{test.expected}}, sut.On{{test.input.planet}}(), precision: 2);
Expand Down
Loading

0 comments on commit 1593833

Please sign in to comment.