trackler 2.2.1.12 → 2.2.1.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/trackler/version.rb +1 -1
- data/problem-specifications/exercises/space-age/description.md +2 -1
- data/problem-specifications/exercises/two-fer/canonical-data.json +4 -4
- data/tracks/csharp/.gitignore +2 -1
- data/tracks/csharp/config/maintainers.json +3 -3
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.cs +1 -1
- data/tracks/csharp/exercises/collatz-conjecture/CollatzConjectureTest.cs +8 -8
- data/tracks/csharp/exercises/collatz-conjecture/Example.cs +6 -6
- data/tracks/csharp/exercises/gigasecond/Example.cs +1 -1
- data/tracks/csharp/exercises/gigasecond/Gigasecond.cs +1 -1
- data/tracks/csharp/exercises/gigasecond/GigasecondTest.cs +21 -10
- data/tracks/csharp/exercises/hamming/Example.cs +6 -1
- data/tracks/csharp/exercises/hamming/Hamming.cs +1 -1
- data/tracks/csharp/exercises/hamming/HammingTest.cs +69 -12
- data/tracks/csharp/exercises/pangram/PangramTest.cs +15 -20
- data/tracks/csharp/exercises/phone-number/Example.cs +15 -42
- data/tracks/csharp/exercises/phone-number/PhoneNumber.cs +2 -17
- data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +57 -20
- data/tracks/csharp/exercises/prime-factors/Example.cs +1 -1
- data/tracks/csharp/exercises/prime-factors/PrimeFactors.cs +1 -1
- data/tracks/csharp/exercises/prime-factors/PrimeFactorsTest.cs +16 -38
- data/tracks/csharp/exercises/rail-fence-cipher/RailFenceCipherTest.cs +21 -19
- data/tracks/csharp/exercises/rna-transcription/Example.cs +7 -2
- data/tracks/csharp/exercises/rna-transcription/RnaTranscription.cs +2 -2
- data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +26 -6
- data/tracks/csharp/exercises/rotational-cipher/RotationalCipherTest.cs +7 -7
- data/tracks/csharp/exercises/run-length-encoding/RunLengthEncodingTest.cs +53 -29
- data/tracks/csharp/exercises/scrabble-score/Example.cs +2 -2
- data/tracks/csharp/exercises/scrabble-score/ScrabbleScore.cs +1 -1
- data/tracks/csharp/exercises/scrabble-score/ScrabbleScoreTest.cs +33 -19
- data/tracks/csharp/exercises/secret-handshake/SecretHandshake.cs +0 -1
- data/tracks/csharp/exercises/secret-handshake/SecretHandshakeTest.cs +36 -10
- data/tracks/csharp/exercises/two-fer/Example.cs +1 -1
- data/tracks/csharp/exercises/two-fer/TwoFer.cs +1 -1
- data/tracks/csharp/exercises/two-fer/TwoFerTest.cs +19 -19
- data/tracks/csharp/generators/.gitignore +1 -1
- data/tracks/csharp/generators/Exercise.cs +85 -10
- data/tracks/csharp/generators/Exercises/AllYourBase.cs +3 -14
- data/tracks/csharp/generators/Exercises/Allergies.cs +21 -18
- data/tracks/csharp/generators/Exercises/Alphametics.cs +6 -7
- data/tracks/csharp/generators/Exercises/Anagram.cs +4 -4
- data/tracks/csharp/generators/Exercises/BeerSong.cs +4 -2
- data/tracks/csharp/generators/Exercises/BinarySearch.cs +3 -3
- data/tracks/csharp/generators/Exercises/BookStore.cs +3 -3
- data/tracks/csharp/generators/Exercises/BracketPush.cs +4 -2
- data/tracks/csharp/generators/Exercises/CollatzConjecture.cs +16 -0
- data/tracks/csharp/generators/Exercises/ConvertExtensions.cs +12 -0
- data/tracks/csharp/generators/Exercises/CryptoSquare.cs +3 -2
- data/tracks/csharp/generators/Exercises/FoodChain.cs +3 -3
- data/tracks/csharp/generators/Exercises/Gigasecond.cs +38 -0
- data/tracks/csharp/generators/Exercises/Hamming.cs +16 -0
- data/tracks/csharp/generators/Exercises/Leap.cs +4 -2
- data/tracks/csharp/generators/Exercises/Luhn.cs +3 -1
- data/tracks/csharp/generators/Exercises/NthPrime.cs +2 -10
- data/tracks/csharp/generators/Exercises/Pangram.cs +17 -0
- data/tracks/csharp/generators/Exercises/PerfectNumbers.cs +2 -9
- data/tracks/csharp/generators/Exercises/PhoneNumber.cs +15 -0
- data/tracks/csharp/generators/Exercises/PrimeFactors.cs +6 -0
- data/tracks/csharp/generators/Exercises/RailFenceCipher.cs +23 -0
- data/tracks/csharp/generators/Exercises/RnaTranscription.cs +6 -0
- data/tracks/csharp/generators/Exercises/RomanNumerals.cs +4 -2
- data/tracks/csharp/generators/Exercises/RunLengthEncoding.cs +40 -0
- data/tracks/csharp/generators/Exercises/ScrabbleScore.cs +6 -0
- data/tracks/csharp/generators/Exercises/SecretHandshake.cs +15 -0
- data/tracks/csharp/generators/Exercises/Transpose.cs +4 -4
- data/tracks/csharp/generators/Exercises/TwoFer.cs +6 -0
- data/tracks/csharp/generators/Exercises/Wordy.cs +2 -10
- data/tracks/csharp/generators/Generators.csproj +1 -3
- data/tracks/csharp/generators/Input/CanonicalDataFile.cs +48 -11
- data/tracks/csharp/generators/Input/CanonicalDataOptions.cs +8 -0
- data/tracks/csharp/generators/Input/CanonicalDataParser.cs +11 -3
- data/tracks/csharp/generators/Options.cs +8 -0
- data/tracks/csharp/generators/Output/{TestClassFile.cs → ExerciseWriter.cs} +4 -3
- data/tracks/csharp/generators/Output/FormattingExtensions.cs +14 -0
- data/tracks/csharp/generators/Output/IndentFilter.cs +13 -0
- data/tracks/csharp/generators/Output/TemplateRenderer.cs +23 -0
- data/tracks/csharp/generators/Output/Templates/_Act.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_Arrange.liquid +3 -0
- data/tracks/csharp/generators/Output/Templates/_AssertBoolean.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertEqual.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertEqual_Empty.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertNull.liquid +1 -0
- data/tracks/csharp/generators/Output/Templates/_AssertThrowsException.liquid +1 -0
- data/tracks/csharp/generators/Output/{TestClass.liquid → Templates/_TestClass.liquid} +2 -8
- data/tracks/csharp/generators/Output/Templates/_TestMethod.liquid +5 -0
- data/tracks/csharp/generators/Output/Templates/_TestMethodBody.liquid +3 -0
- data/tracks/csharp/generators/Output/TestClass.cs +5 -2
- data/tracks/csharp/generators/Output/TestMethod.cs +6 -6
- data/tracks/csharp/generators/Output/TestMethodBody.cs +49 -0
- data/tracks/csharp/generators/Output/TestMethodBodyData.cs +85 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithBooleanCheck.cs +16 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithEqualityCheck.cs +21 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithExceptionCheck.cs +18 -0
- data/tracks/csharp/generators/Output/TestMethodBodyWithNullCheck.cs +13 -0
- data/tracks/csharp/generators/Output/UnescapedValue.cs +6 -2
- data/tracks/csharp/generators/Output/ValueFormatter.cs +1 -10
- data/tracks/csharp/generators/Program.cs +34 -8
- data/tracks/delphi/config/maintainers.json +1 -1
- data/tracks/delphi/docs/{Getting_Started_Guide.md → GETTING_STARTED_GUIDE.md} +0 -0
- data/tracks/fsharp/config.json +16 -5
- data/tracks/fsharp/config/maintainers.json +3 -3
- data/tracks/fsharp/exercises/two-fer/Example.fs +4 -0
- data/tracks/fsharp/exercises/two-fer/README.md +28 -0
- data/tracks/fsharp/exercises/two-fer/TwoFerTest.fs +19 -0
- data/tracks/groovy/CONTRIBUTING.md +19 -0
- data/tracks/groovy/README.md +10 -2
- data/tracks/java/exercises/allergies/src/example/java/Allergies.java +1 -1
- data/tracks/r/bin/run_tests.R +1 -4
- data/tracks/r/docs/{snippet.txt → SNIPPET.txt} +0 -0
- data/tracks/r/exercises/hamming/example.R +1 -1
- data/tracks/ruby/exercises/flatten-array/README.md +1 -1
- data/tracks/scala/exercises/gigasecond/example.scala +3 -3
- data/tracks/scala/exercises/gigasecond/src/main/scala/Gigasecond.scala +2 -2
- data/tracks/scala/exercises/gigasecond/src/test/scala/GigasecondTest.scala +12 -21
- data/tracks/scala/exercises/house/example.scala +6 -3
- data/tracks/scala/exercises/house/src/test/scala/HouseTest.scala +289 -97
- data/tracks/scala/exercises/isogram/src/main/scala/{Isogram.scala → .keep} +0 -0
- data/tracks/scala/exercises/isogram/src/test/scala/IsogramTest.scala +16 -19
- data/tracks/scala/testgen/src/main/scala/GigasecondTestGenerator.scala +49 -0
- data/tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala +47 -0
- data/tracks/scala/testgen/src/main/scala/IsogramTestGenerator.scala +10 -31
- data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +3 -3
- data/tracks/scala/testgen/src/main/twirl/funSuiteTemplate.scala.txt +5 -1
- data/tracks/swift/config.json +11 -0
- data/tracks/swift/exercises/rotational-cipher/.gitignore +4 -0
- data/tracks/swift/exercises/rotational-cipher/Package.swift +5 -0
- data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipher.swift +1 -0
- data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipherExample.swift +30 -0
- data/tracks/swift/exercises/rotational-cipher/Tests/LinuxMain.swift +6 -0
- data/tracks/swift/exercises/rotational-cipher/Tests/RotationalCipherTests/RotationalCipherTests.swift +70 -0
- metadata +51 -17
- data/tracks/csharp/generators/Output/BooleanTestMethodGenerator.cs +0 -13
- data/tracks/csharp/generators/Output/EqualityTestMethodGenerator.cs +0 -27
- data/tracks/csharp/generators/Output/ExceptionTestMethodGenerator.cs +0 -15
- data/tracks/csharp/generators/Output/TestClassGenerator.cs +0 -30
- data/tracks/csharp/generators/Output/TestClassRenderer.cs +0 -26
- data/tracks/csharp/generators/Output/TestMethodGenerator.cs +0 -94
- data/tracks/java/docs/img/eclipse-help-dropdown.png +0 -0
- data/tracks/java/docs/img/eclipse-mp-search-buildship-gradle.png +0 -0
- data/tracks/java/docs/img/mac-osx--idea-ce-run-unit-tests.png +0 -0
- data/tracks/java/docs/img/mac-osx--install-java-dialog.png +0 -0
@@ -1,25 +1,25 @@
|
|
1
|
-
// This file was auto-generated based on version 1.
|
1
|
+
// This file was auto-generated based on version 1.1.0 of the canonical data.
|
2
2
|
|
3
3
|
using Xunit;
|
4
4
|
|
5
5
|
public class RotationalCipherTest
|
6
6
|
{
|
7
7
|
[Fact]
|
8
|
-
public void
|
8
|
+
public void Rotate_a_by_0_same_output_as_input()
|
9
9
|
{
|
10
|
-
Assert.Equal("
|
10
|
+
Assert.Equal("a", RotationalCipher.Rotate("a", 0));
|
11
11
|
}
|
12
12
|
|
13
13
|
[Fact(Skip = "Remove to run test")]
|
14
|
-
public void
|
14
|
+
public void Rotate_a_by_1()
|
15
15
|
{
|
16
|
-
Assert.Equal("
|
16
|
+
Assert.Equal("b", RotationalCipher.Rotate("a", 1));
|
17
17
|
}
|
18
18
|
|
19
19
|
[Fact(Skip = "Remove to run test")]
|
20
|
-
public void
|
20
|
+
public void Rotate_a_by_26_same_output_as_input()
|
21
21
|
{
|
22
|
-
Assert.Equal("a", RotationalCipher.Rotate("a",
|
22
|
+
Assert.Equal("a", RotationalCipher.Rotate("a", 26));
|
23
23
|
}
|
24
24
|
|
25
25
|
[Fact(Skip = "Remove to run test")]
|
@@ -1,60 +1,84 @@
|
|
1
|
-
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
2
|
+
|
3
|
+
using Xunit;
|
2
4
|
|
3
5
|
public class RunLengthEncodingTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
|
-
public void
|
8
|
+
public void Encode_empty_string()
|
9
|
+
{
|
10
|
+
Assert.Equal("", RunLengthEncoding.Encode(""));
|
11
|
+
}
|
12
|
+
|
13
|
+
[Fact(Skip = "Remove to run test")]
|
14
|
+
public void Encode_single_characters_only_are_encoded_without_count()
|
15
|
+
{
|
16
|
+
Assert.Equal("XYZ", RunLengthEncoding.Encode("XYZ"));
|
17
|
+
}
|
18
|
+
|
19
|
+
[Fact(Skip = "Remove to run test")]
|
20
|
+
public void Encode_string_with_no_single_characters()
|
21
|
+
{
|
22
|
+
Assert.Equal("2A3B4C", RunLengthEncoding.Encode("AABBBCCCC"));
|
23
|
+
}
|
24
|
+
|
25
|
+
[Fact(Skip = "Remove to run test")]
|
26
|
+
public void Encode_single_characters_mixed_with_repeated_characters()
|
27
|
+
{
|
28
|
+
Assert.Equal("12WB12W3B24WB", RunLengthEncoding.Encode("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"));
|
29
|
+
}
|
30
|
+
|
31
|
+
[Fact(Skip = "Remove to run test")]
|
32
|
+
public void Encode_multiple_whitespace_mixed_in_string()
|
33
|
+
{
|
34
|
+
Assert.Equal("2 hs2q q2w2 ", RunLengthEncoding.Encode(" hsqq qww "));
|
35
|
+
}
|
36
|
+
|
37
|
+
[Fact(Skip = "Remove to run test")]
|
38
|
+
public void Encode_lowercase_characters()
|
39
|
+
{
|
40
|
+
Assert.Equal("2a3b4c", RunLengthEncoding.Encode("aabbbcccc"));
|
41
|
+
}
|
42
|
+
|
43
|
+
[Fact(Skip = "Remove to run test")]
|
44
|
+
public void Decode_empty_string()
|
7
45
|
{
|
8
|
-
|
9
|
-
const string expected = "2A3B4C";
|
10
|
-
Assert.Equal(expected, RunLengthEncoding.Encode(input));
|
46
|
+
Assert.Equal("", RunLengthEncoding.Decode(""));
|
11
47
|
}
|
12
48
|
|
13
49
|
[Fact(Skip = "Remove to run test")]
|
14
|
-
public void
|
50
|
+
public void Decode_single_characters_only()
|
15
51
|
{
|
16
|
-
|
17
|
-
const string expected = "AABBBCCCC";
|
18
|
-
Assert.Equal(expected, RunLengthEncoding.Decode(input));
|
52
|
+
Assert.Equal("XYZ", RunLengthEncoding.Decode("XYZ"));
|
19
53
|
}
|
20
54
|
|
21
55
|
[Fact(Skip = "Remove to run test")]
|
22
|
-
public void
|
56
|
+
public void Decode_string_with_no_single_characters()
|
23
57
|
{
|
24
|
-
|
25
|
-
const string expected = "12WB12W3B24WB";
|
26
|
-
Assert.Equal(expected, RunLengthEncoding.Encode(input));
|
58
|
+
Assert.Equal("AABBBCCCC", RunLengthEncoding.Decode("2A3B4C"));
|
27
59
|
}
|
28
60
|
|
29
61
|
[Fact(Skip = "Remove to run test")]
|
30
|
-
public void
|
62
|
+
public void Decode_single_characters_with_repeated_characters()
|
31
63
|
{
|
32
|
-
|
33
|
-
const string expected = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB";
|
34
|
-
Assert.Equal(expected, RunLengthEncoding.Decode(input));
|
64
|
+
Assert.Equal("WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB", RunLengthEncoding.Decode("12WB12W3B24WB"));
|
35
65
|
}
|
36
66
|
|
37
67
|
[Fact(Skip = "Remove to run test")]
|
38
|
-
public void
|
68
|
+
public void Decode_multiple_whitespace_mixed_in_string()
|
39
69
|
{
|
40
|
-
|
41
|
-
const string expected = "zzz ZZ zZ";
|
42
|
-
Assert.Equal(expected, RunLengthEncoding.Decode(RunLengthEncoding.Encode(input)));
|
70
|
+
Assert.Equal(" hsqq qww ", RunLengthEncoding.Decode("2 hs2q q2w2 "));
|
43
71
|
}
|
44
72
|
|
45
73
|
[Fact(Skip = "Remove to run test")]
|
46
|
-
public void
|
74
|
+
public void Decode_lower_case_string()
|
47
75
|
{
|
48
|
-
|
49
|
-
const string expected = "⏰3⚽2⭐⏰";
|
50
|
-
Assert.Equal(expected, RunLengthEncoding.Encode(input));
|
76
|
+
Assert.Equal("aabbbcccc", RunLengthEncoding.Decode("2a3b4c"));
|
51
77
|
}
|
52
78
|
|
53
79
|
[Fact(Skip = "Remove to run test")]
|
54
|
-
public void
|
80
|
+
public void Consistency_encode_followed_by_decode_gives_original_string()
|
55
81
|
{
|
56
|
-
|
57
|
-
const string expected = "⏰⚽⚽⚽⭐⭐⏰";
|
58
|
-
Assert.Equal(expected, RunLengthEncoding.Decode(input));
|
82
|
+
Assert.Equal("zzz ZZ zZ", RunLengthEncoding.Decode(RunLengthEncoding.Encode("zzz ZZ zZ")));
|
59
83
|
}
|
60
84
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
using System.Collections.Generic;
|
2
2
|
using System.Linq;
|
3
3
|
|
4
|
-
public class
|
4
|
+
public static class ScrabbleScore
|
5
5
|
{
|
6
6
|
private static readonly Dictionary<char, int> LetterScores = new Dictionary<char, int>
|
7
7
|
{
|
@@ -21,4 +21,4 @@ public static int Score(string input)
|
|
21
21
|
|
22
22
|
return input.ToLower().Sum(x => LetterScores[x]);
|
23
23
|
}
|
24
|
-
}
|
24
|
+
}
|
@@ -1,58 +1,72 @@
|
|
1
|
+
// This file was auto-generated based on version 1.0.0 of the canonical data.
|
2
|
+
|
1
3
|
using Xunit;
|
2
4
|
|
3
5
|
public class ScrabbleScoreTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
|
-
public void
|
8
|
+
public void Lowercase_letter()
|
9
|
+
{
|
10
|
+
Assert.Equal(1, ScrabbleScore.Score("a"));
|
11
|
+
}
|
12
|
+
|
13
|
+
[Fact(Skip = "Remove to run test")]
|
14
|
+
public void Uppercase_letter()
|
7
15
|
{
|
8
|
-
Assert.Equal(
|
16
|
+
Assert.Equal(1, ScrabbleScore.Score("A"));
|
9
17
|
}
|
10
18
|
|
11
19
|
[Fact(Skip = "Remove to run test")]
|
12
|
-
public void
|
20
|
+
public void Valuable_letter()
|
13
21
|
{
|
14
|
-
Assert.Equal(
|
22
|
+
Assert.Equal(4, ScrabbleScore.Score("f"));
|
15
23
|
}
|
16
24
|
|
17
25
|
[Fact(Skip = "Remove to run test")]
|
18
|
-
public void
|
26
|
+
public void Short_word()
|
19
27
|
{
|
20
|
-
Assert.Equal(
|
28
|
+
Assert.Equal(2, ScrabbleScore.Score("at"));
|
21
29
|
}
|
22
30
|
|
23
31
|
[Fact(Skip = "Remove to run test")]
|
24
|
-
public void
|
32
|
+
public void Short_valuable_word()
|
25
33
|
{
|
26
|
-
Assert.Equal(
|
34
|
+
Assert.Equal(12, ScrabbleScore.Score("zoo"));
|
27
35
|
}
|
28
36
|
|
29
37
|
[Fact(Skip = "Remove to run test")]
|
30
|
-
public void
|
38
|
+
public void Medium_word()
|
31
39
|
{
|
32
|
-
Assert.Equal(
|
40
|
+
Assert.Equal(6, ScrabbleScore.Score("street"));
|
33
41
|
}
|
34
42
|
|
35
43
|
[Fact(Skip = "Remove to run test")]
|
36
|
-
public void
|
44
|
+
public void Medium_valuable_word()
|
37
45
|
{
|
38
|
-
Assert.Equal(
|
46
|
+
Assert.Equal(22, ScrabbleScore.Score("quirky"));
|
39
47
|
}
|
40
48
|
|
41
49
|
[Fact(Skip = "Remove to run test")]
|
42
|
-
public void
|
50
|
+
public void Long_mixed_case_word()
|
43
51
|
{
|
44
|
-
Assert.Equal(
|
52
|
+
Assert.Equal(41, ScrabbleScore.Score("OxyphenButazone"));
|
45
53
|
}
|
46
54
|
|
47
55
|
[Fact(Skip = "Remove to run test")]
|
48
|
-
public void
|
56
|
+
public void English_like_word()
|
49
57
|
{
|
50
|
-
Assert.Equal(
|
58
|
+
Assert.Equal(8, ScrabbleScore.Score("pinata"));
|
51
59
|
}
|
52
|
-
|
60
|
+
|
61
|
+
[Fact(Skip = "Remove to run test")]
|
62
|
+
public void Empty_input()
|
63
|
+
{
|
64
|
+
Assert.Equal(0, ScrabbleScore.Score(""));
|
65
|
+
}
|
66
|
+
|
53
67
|
[Fact(Skip = "Remove to run test")]
|
54
|
-
public void
|
68
|
+
public void Entire_alphabet_available()
|
55
69
|
{
|
56
|
-
Assert.Equal(87,
|
70
|
+
Assert.Equal(87, ScrabbleScore.Score("abcdefghijklmnopqrstuvwxyz"));
|
57
71
|
}
|
58
72
|
}
|
@@ -1,46 +1,72 @@
|
|
1
|
-
|
1
|
+
// This file was auto-generated based on version 1.1.0 of the canonical data.
|
2
2
|
|
3
|
-
|
3
|
+
using Xunit;
|
4
|
+
|
5
|
+
public class SecretHandshakeTest
|
4
6
|
{
|
5
7
|
[Fact]
|
6
|
-
public void
|
8
|
+
public void Wink_for_1()
|
7
9
|
{
|
8
10
|
Assert.Equal(new[] { "wink" }, SecretHandshake.Commands(1));
|
9
11
|
}
|
10
12
|
|
11
13
|
[Fact(Skip = "Remove to run test")]
|
12
|
-
public void
|
14
|
+
public void Double_blink_for_10()
|
13
15
|
{
|
14
16
|
Assert.Equal(new[] { "double blink" }, SecretHandshake.Commands(2));
|
15
17
|
}
|
16
18
|
|
17
19
|
[Fact(Skip = "Remove to run test")]
|
18
|
-
public void
|
20
|
+
public void Close_your_eyes_for_100()
|
19
21
|
{
|
20
22
|
Assert.Equal(new[] { "close your eyes" }, SecretHandshake.Commands(4));
|
21
23
|
}
|
22
24
|
|
23
25
|
[Fact(Skip = "Remove to run test")]
|
24
|
-
public void
|
26
|
+
public void Jump_for_1000()
|
25
27
|
{
|
26
28
|
Assert.Equal(new[] { "jump" }, SecretHandshake.Commands(8));
|
27
29
|
}
|
28
30
|
|
29
31
|
[Fact(Skip = "Remove to run test")]
|
30
|
-
public void
|
32
|
+
public void Combine_two_actions()
|
31
33
|
{
|
32
34
|
Assert.Equal(new[] { "wink", "double blink" }, SecretHandshake.Commands(3));
|
33
35
|
}
|
34
36
|
|
35
37
|
[Fact(Skip = "Remove to run test")]
|
36
|
-
public void
|
38
|
+
public void Reverse_two_actions()
|
37
39
|
{
|
38
40
|
Assert.Equal(new[] { "double blink", "wink" }, SecretHandshake.Commands(19));
|
39
41
|
}
|
40
42
|
|
41
43
|
[Fact(Skip = "Remove to run test")]
|
42
|
-
public void
|
44
|
+
public void Reversing_one_action_gives_the_same_action()
|
45
|
+
{
|
46
|
+
Assert.Equal(new[] { "jump" }, SecretHandshake.Commands(24));
|
47
|
+
}
|
48
|
+
|
49
|
+
[Fact(Skip = "Remove to run test")]
|
50
|
+
public void Reversing_no_actions_still_gives_no_actions()
|
51
|
+
{
|
52
|
+
Assert.Empty(SecretHandshake.Commands(16));
|
53
|
+
}
|
54
|
+
|
55
|
+
[Fact(Skip = "Remove to run test")]
|
56
|
+
public void All_possible_actions()
|
57
|
+
{
|
58
|
+
Assert.Equal(new[] { "wink", "double blink", "close your eyes", "jump" }, SecretHandshake.Commands(15));
|
59
|
+
}
|
60
|
+
|
61
|
+
[Fact(Skip = "Remove to run test")]
|
62
|
+
public void Reverse_all_possible_actions()
|
43
63
|
{
|
44
64
|
Assert.Equal(new[] { "jump", "close your eyes", "double blink", "wink" }, SecretHandshake.Commands(31));
|
45
65
|
}
|
46
|
-
|
66
|
+
|
67
|
+
[Fact(Skip = "Remove to run test")]
|
68
|
+
public void Do_nothing_for_zero()
|
69
|
+
{
|
70
|
+
Assert.Empty(SecretHandshake.Commands(0));
|
71
|
+
}
|
72
|
+
}
|
@@ -1,24 +1,24 @@
|
|
1
|
-
|
1
|
+
// This file was auto-generated based on version 1.1.0 of the canonical data.
|
2
2
|
|
3
3
|
using Xunit;
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
public class TwoFerTest
|
6
|
+
{
|
7
|
+
[Fact]
|
8
|
+
public void No_name_given()
|
9
|
+
{
|
10
|
+
Assert.Equal("One for you, one for me.", TwoFer.Name());
|
11
|
+
}
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
[Fact(Skip = "Remove to run test")]
|
14
|
+
public void A_name_given()
|
15
|
+
{
|
16
|
+
Assert.Equal("One for Alice, one for me.", TwoFer.Name("Alice"));
|
17
|
+
}
|
18
18
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
[Fact(Skip = "Remove to run test")]
|
20
|
+
public void Another_name_given()
|
21
|
+
{
|
22
|
+
Assert.Equal("One for Bob, one for me.", TwoFer.Name("Bob"));
|
23
|
+
}
|
24
|
+
}
|
@@ -1,2 +1,2 @@
|
|
1
|
-
.
|
1
|
+
.problem-specifications/
|
2
2
|
Properties/launchSettings.json
|
@@ -1,23 +1,98 @@
|
|
1
|
-
using
|
1
|
+
using System.Collections.Generic;
|
2
|
+
using System.Linq;
|
3
|
+
using Generators.Input;
|
2
4
|
using Generators.Output;
|
3
5
|
|
4
6
|
namespace Generators
|
5
7
|
{
|
6
8
|
public abstract class Exercise
|
7
9
|
{
|
8
|
-
|
10
|
+
private static readonly ExerciseWriter ExerciseWriter = new ExerciseWriter();
|
11
|
+
|
12
|
+
public string Name => GetType().ToExerciseName();
|
13
|
+
|
14
|
+
protected CanonicalData CanonicalData { get; private set; }
|
15
|
+
|
16
|
+
public void Regenerate(CanonicalData canonicalData)
|
17
|
+
{
|
18
|
+
CanonicalData = canonicalData;
|
19
|
+
UpdateCanonicalData(CanonicalData);
|
20
|
+
|
21
|
+
ExerciseWriter.WriteToFile(this);
|
22
|
+
}
|
23
|
+
|
24
|
+
protected virtual void UpdateCanonicalData(CanonicalData canonicalData)
|
25
|
+
{
|
26
|
+
}
|
27
|
+
|
28
|
+
public virtual string Render() => CreateTestClass().Render();
|
29
|
+
|
30
|
+
protected virtual TestClass CreateTestClass() => new TestClass
|
31
|
+
{
|
32
|
+
ClassName = Name.ToTestClassName(),
|
33
|
+
Methods = RenderTestMethods(),
|
34
|
+
CanonicalDataVersion = CanonicalData.Version,
|
35
|
+
UsingNamespaces = GetUsingNamespaces()
|
36
|
+
};
|
37
|
+
|
38
|
+
protected virtual HashSet<string> GetUsingNamespaces()
|
39
|
+
{
|
40
|
+
var usingNamespaces = new HashSet<string> { "Xunit" };
|
41
|
+
|
42
|
+
foreach (var canonicalDataCase in CanonicalData.Cases.Where(canonicalDataCase => canonicalDataCase.ExceptionThrown != null))
|
43
|
+
usingNamespaces.Add(canonicalDataCase.ExceptionThrown.Namespace);
|
44
|
+
|
45
|
+
return usingNamespaces;
|
46
|
+
}
|
47
|
+
|
48
|
+
protected virtual string[] RenderTestMethods() => CanonicalData.Cases.Select(RenderTestMethod).ToArray();
|
49
|
+
|
50
|
+
protected virtual string RenderTestMethod(CanonicalDataCase canonicalDataCase, int index) => CreateTestMethod(canonicalDataCase, index).Render();
|
51
|
+
|
52
|
+
protected virtual TestMethod CreateTestMethod(CanonicalDataCase canonicalDataCase, int index) => new TestMethod
|
53
|
+
{
|
54
|
+
Skip = index > 0,
|
55
|
+
Name = canonicalDataCase.Description.ToTestMethodName(),
|
56
|
+
Body = RenderTestMethodBody(canonicalDataCase)
|
57
|
+
};
|
58
|
+
|
59
|
+
protected virtual string RenderTestMethodBody(CanonicalDataCase canonicalDataCase)
|
9
60
|
{
|
10
|
-
|
11
|
-
|
61
|
+
var testMethodBody = CreateTestMethodBody(canonicalDataCase);
|
62
|
+
testMethodBody.Arrange = RenderTestMethodBodyArrange(testMethodBody);
|
63
|
+
testMethodBody.Act = RenderTestMethodBodyAct(testMethodBody);
|
64
|
+
testMethodBody.Assert = RenderTestMethodBodyAssert(testMethodBody);
|
65
|
+
|
66
|
+
return testMethodBody.Render();
|
12
67
|
}
|
13
68
|
|
14
|
-
|
15
|
-
|
69
|
+
protected virtual TestMethodBody CreateTestMethodBody(CanonicalDataCase canonicalDataCase)
|
70
|
+
{
|
71
|
+
if (canonicalDataCase.ExceptionThrown != null)
|
72
|
+
{
|
73
|
+
return new TestMethodBodyWithExceptionCheck(canonicalDataCase, CanonicalData);
|
74
|
+
}
|
75
|
+
|
76
|
+
if (canonicalDataCase.Expected is bool)
|
77
|
+
{
|
78
|
+
return new TestMethodBodyWithBooleanCheck(canonicalDataCase, CanonicalData);
|
79
|
+
}
|
80
|
+
|
81
|
+
if (canonicalDataCase.Expected is null)
|
82
|
+
{
|
83
|
+
return new TestMethodBodyWithNullCheck(canonicalDataCase, CanonicalData);
|
84
|
+
}
|
85
|
+
|
86
|
+
return new TestMethodBodyWithEqualityCheck(canonicalDataCase, CanonicalData);
|
87
|
+
}
|
16
88
|
|
17
|
-
|
89
|
+
protected virtual string RenderTestMethodBodyArrange(TestMethodBody testMethodBody)
|
90
|
+
=> TemplateRenderer.RenderPartial(testMethodBody.ArrangeTemplateName, testMethodBody.ArrangeTemplateParameters);
|
18
91
|
|
19
|
-
protected virtual string
|
92
|
+
protected virtual string RenderTestMethodBodyAct(TestMethodBody testMethodBody)
|
93
|
+
=> TemplateRenderer.RenderPartial(testMethodBody.ActTemplateName, testMethodBody.ActTemplateParameters);
|
20
94
|
|
21
|
-
protected virtual
|
95
|
+
protected virtual string RenderTestMethodBodyAssert(TestMethodBody testMethodBody)
|
96
|
+
=> TemplateRenderer.RenderPartial(testMethodBody.AssertTemplateName, testMethodBody.AssertTemplateParameters);
|
22
97
|
}
|
23
|
-
}
|
98
|
+
}
|