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.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/problem-specifications/exercises/space-age/description.md +2 -1
  4. data/problem-specifications/exercises/two-fer/canonical-data.json +4 -4
  5. data/tracks/csharp/.gitignore +2 -1
  6. data/tracks/csharp/config/maintainers.json +3 -3
  7. data/tracks/csharp/exercises/collatz-conjecture/CollatzConjecture.cs +1 -1
  8. data/tracks/csharp/exercises/collatz-conjecture/CollatzConjectureTest.cs +8 -8
  9. data/tracks/csharp/exercises/collatz-conjecture/Example.cs +6 -6
  10. data/tracks/csharp/exercises/gigasecond/Example.cs +1 -1
  11. data/tracks/csharp/exercises/gigasecond/Gigasecond.cs +1 -1
  12. data/tracks/csharp/exercises/gigasecond/GigasecondTest.cs +21 -10
  13. data/tracks/csharp/exercises/hamming/Example.cs +6 -1
  14. data/tracks/csharp/exercises/hamming/Hamming.cs +1 -1
  15. data/tracks/csharp/exercises/hamming/HammingTest.cs +69 -12
  16. data/tracks/csharp/exercises/pangram/PangramTest.cs +15 -20
  17. data/tracks/csharp/exercises/phone-number/Example.cs +15 -42
  18. data/tracks/csharp/exercises/phone-number/PhoneNumber.cs +2 -17
  19. data/tracks/csharp/exercises/phone-number/PhoneNumberTest.cs +57 -20
  20. data/tracks/csharp/exercises/prime-factors/Example.cs +1 -1
  21. data/tracks/csharp/exercises/prime-factors/PrimeFactors.cs +1 -1
  22. data/tracks/csharp/exercises/prime-factors/PrimeFactorsTest.cs +16 -38
  23. data/tracks/csharp/exercises/rail-fence-cipher/RailFenceCipherTest.cs +21 -19
  24. data/tracks/csharp/exercises/rna-transcription/Example.cs +7 -2
  25. data/tracks/csharp/exercises/rna-transcription/RnaTranscription.cs +2 -2
  26. data/tracks/csharp/exercises/rna-transcription/RnaTranscriptionTest.cs +26 -6
  27. data/tracks/csharp/exercises/rotational-cipher/RotationalCipherTest.cs +7 -7
  28. data/tracks/csharp/exercises/run-length-encoding/RunLengthEncodingTest.cs +53 -29
  29. data/tracks/csharp/exercises/scrabble-score/Example.cs +2 -2
  30. data/tracks/csharp/exercises/scrabble-score/ScrabbleScore.cs +1 -1
  31. data/tracks/csharp/exercises/scrabble-score/ScrabbleScoreTest.cs +33 -19
  32. data/tracks/csharp/exercises/secret-handshake/SecretHandshake.cs +0 -1
  33. data/tracks/csharp/exercises/secret-handshake/SecretHandshakeTest.cs +36 -10
  34. data/tracks/csharp/exercises/two-fer/Example.cs +1 -1
  35. data/tracks/csharp/exercises/two-fer/TwoFer.cs +1 -1
  36. data/tracks/csharp/exercises/two-fer/TwoFerTest.cs +19 -19
  37. data/tracks/csharp/generators/.gitignore +1 -1
  38. data/tracks/csharp/generators/Exercise.cs +85 -10
  39. data/tracks/csharp/generators/Exercises/AllYourBase.cs +3 -14
  40. data/tracks/csharp/generators/Exercises/Allergies.cs +21 -18
  41. data/tracks/csharp/generators/Exercises/Alphametics.cs +6 -7
  42. data/tracks/csharp/generators/Exercises/Anagram.cs +4 -4
  43. data/tracks/csharp/generators/Exercises/BeerSong.cs +4 -2
  44. data/tracks/csharp/generators/Exercises/BinarySearch.cs +3 -3
  45. data/tracks/csharp/generators/Exercises/BookStore.cs +3 -3
  46. data/tracks/csharp/generators/Exercises/BracketPush.cs +4 -2
  47. data/tracks/csharp/generators/Exercises/CollatzConjecture.cs +16 -0
  48. data/tracks/csharp/generators/Exercises/ConvertExtensions.cs +12 -0
  49. data/tracks/csharp/generators/Exercises/CryptoSquare.cs +3 -2
  50. data/tracks/csharp/generators/Exercises/FoodChain.cs +3 -3
  51. data/tracks/csharp/generators/Exercises/Gigasecond.cs +38 -0
  52. data/tracks/csharp/generators/Exercises/Hamming.cs +16 -0
  53. data/tracks/csharp/generators/Exercises/Leap.cs +4 -2
  54. data/tracks/csharp/generators/Exercises/Luhn.cs +3 -1
  55. data/tracks/csharp/generators/Exercises/NthPrime.cs +2 -10
  56. data/tracks/csharp/generators/Exercises/Pangram.cs +17 -0
  57. data/tracks/csharp/generators/Exercises/PerfectNumbers.cs +2 -9
  58. data/tracks/csharp/generators/Exercises/PhoneNumber.cs +15 -0
  59. data/tracks/csharp/generators/Exercises/PrimeFactors.cs +6 -0
  60. data/tracks/csharp/generators/Exercises/RailFenceCipher.cs +23 -0
  61. data/tracks/csharp/generators/Exercises/RnaTranscription.cs +6 -0
  62. data/tracks/csharp/generators/Exercises/RomanNumerals.cs +4 -2
  63. data/tracks/csharp/generators/Exercises/RunLengthEncoding.cs +40 -0
  64. data/tracks/csharp/generators/Exercises/ScrabbleScore.cs +6 -0
  65. data/tracks/csharp/generators/Exercises/SecretHandshake.cs +15 -0
  66. data/tracks/csharp/generators/Exercises/Transpose.cs +4 -4
  67. data/tracks/csharp/generators/Exercises/TwoFer.cs +6 -0
  68. data/tracks/csharp/generators/Exercises/Wordy.cs +2 -10
  69. data/tracks/csharp/generators/Generators.csproj +1 -3
  70. data/tracks/csharp/generators/Input/CanonicalDataFile.cs +48 -11
  71. data/tracks/csharp/generators/Input/CanonicalDataOptions.cs +8 -0
  72. data/tracks/csharp/generators/Input/CanonicalDataParser.cs +11 -3
  73. data/tracks/csharp/generators/Options.cs +8 -0
  74. data/tracks/csharp/generators/Output/{TestClassFile.cs → ExerciseWriter.cs} +4 -3
  75. data/tracks/csharp/generators/Output/FormattingExtensions.cs +14 -0
  76. data/tracks/csharp/generators/Output/IndentFilter.cs +13 -0
  77. data/tracks/csharp/generators/Output/TemplateRenderer.cs +23 -0
  78. data/tracks/csharp/generators/Output/Templates/_Act.liquid +1 -0
  79. data/tracks/csharp/generators/Output/Templates/_Arrange.liquid +3 -0
  80. data/tracks/csharp/generators/Output/Templates/_AssertBoolean.liquid +1 -0
  81. data/tracks/csharp/generators/Output/Templates/_AssertEqual.liquid +1 -0
  82. data/tracks/csharp/generators/Output/Templates/_AssertEqual_Empty.liquid +1 -0
  83. data/tracks/csharp/generators/Output/Templates/_AssertNull.liquid +1 -0
  84. data/tracks/csharp/generators/Output/Templates/_AssertThrowsException.liquid +1 -0
  85. data/tracks/csharp/generators/Output/{TestClass.liquid → Templates/_TestClass.liquid} +2 -8
  86. data/tracks/csharp/generators/Output/Templates/_TestMethod.liquid +5 -0
  87. data/tracks/csharp/generators/Output/Templates/_TestMethodBody.liquid +3 -0
  88. data/tracks/csharp/generators/Output/TestClass.cs +5 -2
  89. data/tracks/csharp/generators/Output/TestMethod.cs +6 -6
  90. data/tracks/csharp/generators/Output/TestMethodBody.cs +49 -0
  91. data/tracks/csharp/generators/Output/TestMethodBodyData.cs +85 -0
  92. data/tracks/csharp/generators/Output/TestMethodBodyWithBooleanCheck.cs +16 -0
  93. data/tracks/csharp/generators/Output/TestMethodBodyWithEqualityCheck.cs +21 -0
  94. data/tracks/csharp/generators/Output/TestMethodBodyWithExceptionCheck.cs +18 -0
  95. data/tracks/csharp/generators/Output/TestMethodBodyWithNullCheck.cs +13 -0
  96. data/tracks/csharp/generators/Output/UnescapedValue.cs +6 -2
  97. data/tracks/csharp/generators/Output/ValueFormatter.cs +1 -10
  98. data/tracks/csharp/generators/Program.cs +34 -8
  99. data/tracks/delphi/config/maintainers.json +1 -1
  100. data/tracks/delphi/docs/{Getting_Started_Guide.md → GETTING_STARTED_GUIDE.md} +0 -0
  101. data/tracks/fsharp/config.json +16 -5
  102. data/tracks/fsharp/config/maintainers.json +3 -3
  103. data/tracks/fsharp/exercises/two-fer/Example.fs +4 -0
  104. data/tracks/fsharp/exercises/two-fer/README.md +28 -0
  105. data/tracks/fsharp/exercises/two-fer/TwoFerTest.fs +19 -0
  106. data/tracks/groovy/CONTRIBUTING.md +19 -0
  107. data/tracks/groovy/README.md +10 -2
  108. data/tracks/java/exercises/allergies/src/example/java/Allergies.java +1 -1
  109. data/tracks/r/bin/run_tests.R +1 -4
  110. data/tracks/r/docs/{snippet.txt → SNIPPET.txt} +0 -0
  111. data/tracks/r/exercises/hamming/example.R +1 -1
  112. data/tracks/ruby/exercises/flatten-array/README.md +1 -1
  113. data/tracks/scala/exercises/gigasecond/example.scala +3 -3
  114. data/tracks/scala/exercises/gigasecond/src/main/scala/Gigasecond.scala +2 -2
  115. data/tracks/scala/exercises/gigasecond/src/test/scala/GigasecondTest.scala +12 -21
  116. data/tracks/scala/exercises/house/example.scala +6 -3
  117. data/tracks/scala/exercises/house/src/test/scala/HouseTest.scala +289 -97
  118. data/tracks/scala/exercises/isogram/src/main/scala/{Isogram.scala → .keep} +0 -0
  119. data/tracks/scala/exercises/isogram/src/test/scala/IsogramTest.scala +16 -19
  120. data/tracks/scala/testgen/src/main/scala/GigasecondTestGenerator.scala +49 -0
  121. data/tracks/scala/testgen/src/main/scala/HouseTestGenerator.scala +47 -0
  122. data/tracks/scala/testgen/src/main/scala/IsogramTestGenerator.scala +10 -31
  123. data/tracks/scala/testgen/src/main/scala/testgen/TestSuiteBuilder.scala +3 -3
  124. data/tracks/scala/testgen/src/main/twirl/funSuiteTemplate.scala.txt +5 -1
  125. data/tracks/swift/config.json +11 -0
  126. data/tracks/swift/exercises/rotational-cipher/.gitignore +4 -0
  127. data/tracks/swift/exercises/rotational-cipher/Package.swift +5 -0
  128. data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipher.swift +1 -0
  129. data/tracks/swift/exercises/rotational-cipher/Sources/RotationalCipherExample.swift +30 -0
  130. data/tracks/swift/exercises/rotational-cipher/Tests/LinuxMain.swift +6 -0
  131. data/tracks/swift/exercises/rotational-cipher/Tests/RotationalCipherTests/RotationalCipherTests.swift +70 -0
  132. metadata +51 -17
  133. data/tracks/csharp/generators/Output/BooleanTestMethodGenerator.cs +0 -13
  134. data/tracks/csharp/generators/Output/EqualityTestMethodGenerator.cs +0 -27
  135. data/tracks/csharp/generators/Output/ExceptionTestMethodGenerator.cs +0 -15
  136. data/tracks/csharp/generators/Output/TestClassGenerator.cs +0 -30
  137. data/tracks/csharp/generators/Output/TestClassRenderer.cs +0 -26
  138. data/tracks/csharp/generators/Output/TestMethodGenerator.cs +0 -94
  139. data/tracks/java/docs/img/eclipse-help-dropdown.png +0 -0
  140. data/tracks/java/docs/img/eclipse-mp-search-buildship-gradle.png +0 -0
  141. data/tracks/java/docs/img/mac-osx--idea-ce-run-unit-tests.png +0 -0
  142. 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.0.0 of the canonical data.
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 Rotate_a_by_1()
8
+ public void Rotate_a_by_0_same_output_as_input()
9
9
  {
10
- Assert.Equal("b", RotationalCipher.Rotate("a", 1));
10
+ Assert.Equal("a", RotationalCipher.Rotate("a", 0));
11
11
  }
12
12
 
13
13
  [Fact(Skip = "Remove to run test")]
14
- public void Rotate_a_by_26_same_output_as_input()
14
+ public void Rotate_a_by_1()
15
15
  {
16
- Assert.Equal("a", RotationalCipher.Rotate("a", 26));
16
+ Assert.Equal("b", RotationalCipher.Rotate("a", 1));
17
17
  }
18
18
 
19
19
  [Fact(Skip = "Remove to run test")]
20
- public void Rotate_a_by_0_same_output_as_input()
20
+ public void Rotate_a_by_26_same_output_as_input()
21
21
  {
22
- Assert.Equal("a", RotationalCipher.Rotate("a", 0));
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
- using Xunit;
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 Encode_simple()
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
- const string input = "AABBBCCCC";
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 Decode_simple()
50
+ public void Decode_single_characters_only()
15
51
  {
16
- const string input = "2A3B4C";
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 Encode_with_single_values()
56
+ public void Decode_string_with_no_single_characters()
23
57
  {
24
- const string input = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB";
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 Decode_with_single_values()
62
+ public void Decode_single_characters_with_repeated_characters()
31
63
  {
32
- const string input = "12WB12W3B24WB";
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 Encode_and_then_decode()
68
+ public void Decode_multiple_whitespace_mixed_in_string()
39
69
  {
40
- const string input = "zzz ZZ zZ";
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 Encode_unicode()
74
+ public void Decode_lower_case_string()
47
75
  {
48
- const string input = "⏰⚽⚽⚽⭐⭐⏰";
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 Decode_unicode()
80
+ public void Consistency_encode_followed_by_decode_gives_original_string()
55
81
  {
56
- const string input = "⏰3⚽2⭐⏰";
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 Scrabble
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,6 +1,6 @@
1
1
  using System;
2
2
 
3
- public static class Scrabble
3
+ public static class ScrabbleScore
4
4
  {
5
5
  public static int Score(string input)
6
6
  {
@@ -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 Empty_word_scores_zero()
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(0, Scrabble.Score(""));
16
+ Assert.Equal(1, ScrabbleScore.Score("A"));
9
17
  }
10
18
 
11
19
  [Fact(Skip = "Remove to run test")]
12
- public void Whitespace_scores_zero()
20
+ public void Valuable_letter()
13
21
  {
14
- Assert.Equal(0, Scrabble.Score(" \t\n"));
22
+ Assert.Equal(4, ScrabbleScore.Score("f"));
15
23
  }
16
24
 
17
25
  [Fact(Skip = "Remove to run test")]
18
- public void Null_scores_zero()
26
+ public void Short_word()
19
27
  {
20
- Assert.Equal(0, Scrabble.Score(null));
28
+ Assert.Equal(2, ScrabbleScore.Score("at"));
21
29
  }
22
30
 
23
31
  [Fact(Skip = "Remove to run test")]
24
- public void Scores_very_short_word()
32
+ public void Short_valuable_word()
25
33
  {
26
- Assert.Equal(1, Scrabble.Score("a"));
34
+ Assert.Equal(12, ScrabbleScore.Score("zoo"));
27
35
  }
28
36
 
29
37
  [Fact(Skip = "Remove to run test")]
30
- public void Scores_other_very_short_word()
38
+ public void Medium_word()
31
39
  {
32
- Assert.Equal(4, Scrabble.Score("f"));
40
+ Assert.Equal(6, ScrabbleScore.Score("street"));
33
41
  }
34
42
 
35
43
  [Fact(Skip = "Remove to run test")]
36
- public void Simple_word_scores_the_number_of_letters()
44
+ public void Medium_valuable_word()
37
45
  {
38
- Assert.Equal(6, Scrabble.Score("street"));
46
+ Assert.Equal(22, ScrabbleScore.Score("quirky"));
39
47
  }
40
48
 
41
49
  [Fact(Skip = "Remove to run test")]
42
- public void Complicated_word_scores_more()
50
+ public void Long_mixed_case_word()
43
51
  {
44
- Assert.Equal(22, Scrabble.Score("quirky"));
52
+ Assert.Equal(41, ScrabbleScore.Score("OxyphenButazone"));
45
53
  }
46
54
 
47
55
  [Fact(Skip = "Remove to run test")]
48
- public void Scores_are_case_insensitive()
56
+ public void English_like_word()
49
57
  {
50
- Assert.Equal(41, Scrabble.Score("OXYPHENBUTAZONE"));
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 Entire_alphabet()
68
+ public void Entire_alphabet_available()
55
69
  {
56
- Assert.Equal(87, Scrabble.Score("abcdefghijklmnopqrstuvwxyz"));
70
+ Assert.Equal(87, ScrabbleScore.Score("abcdefghijklmnopqrstuvwxyz"));
57
71
  }
58
72
  }
@@ -1,5 +1,4 @@
1
1
  using System;
2
- using System.Linq;
3
2
 
4
3
  public static class SecretHandshake
5
4
  {
@@ -1,46 +1,72 @@
1
- using Xunit;
1
+ // This file was auto-generated based on version 1.1.0 of the canonical data.
2
2
 
3
- public class SecretHandshakeTests
3
+ using Xunit;
4
+
5
+ public class SecretHandshakeTest
4
6
  {
5
7
  [Fact]
6
- public void Test_1_handshake_to_wink()
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 Test_10_handshake_to_double_blink()
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 Test_100_handshake_to_close_your_eyes()
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 Test_1000_handshake_to_close_your_eyes()
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 Test_handshake_11_to_wink_and_double_blink()
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 Test_handshake_10011_to_double_blink_and_wink()
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 Test_handshake_11111_to_all_commands_reversed()
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
+ }
@@ -4,7 +4,7 @@
4
4
 
5
5
  public static class TwoFer
6
6
  {
7
- public static string GetResponse(string input = null)
7
+ public static string Name(string input = null)
8
8
  {
9
9
  if(string.IsNullOrWhiteSpace(input))
10
10
  {
@@ -2,7 +2,7 @@
2
2
 
3
3
  public static class TwoFer
4
4
  {
5
- public static string GetResponse(string input = null)
5
+ public static string Name(string input = null)
6
6
  {
7
7
  throw new NotImplementedException("You need to implement this function.");
8
8
  }
@@ -1,24 +1,24 @@
1
- // This file was auto-generated based on version 1.0.0 of the canonical data.
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
- public class TwoFerTest
6
- {
7
- [Fact]
8
- public void No_name_given()
9
- {
10
- Assert.Equal("One for you, one for me.", TwoFer.GetResponse());
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
- [Fact(Skip = "Remove to run test")]
14
- public void Name_is_given()
15
- {
16
- Assert.Equal("One for Alice, one for me.", TwoFer.GetResponse("Alice"));
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
- [Fact(Skip = "Remove to run test")]
20
- public void Another_name_is_given()
21
- {
22
- Assert.Equal("One for Bob, one for me.", TwoFer.GetResponse("Bob"));
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
- .cache/
1
+ .problem-specifications/
2
2
  Properties/launchSettings.json
@@ -1,23 +1,98 @@
1
- using Generators.Input;
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
- protected Exercise()
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
- Name = GetType().ToExerciseName();
11
- CanonicalData = CanonicalDataParser.Parse(Name);
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
- public string Name { get; }
15
- public CanonicalData CanonicalData { get; }
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
- public void Generate() => TestClassFile.Write(this, Render());
89
+ protected virtual string RenderTestMethodBodyArrange(TestMethodBody testMethodBody)
90
+ => TemplateRenderer.RenderPartial(testMethodBody.ArrangeTemplateName, testMethodBody.ArrangeTemplateParameters);
18
91
 
19
- protected virtual string Render() => TestClassRenderer.Render(CreateTestClass());
92
+ protected virtual string RenderTestMethodBodyAct(TestMethodBody testMethodBody)
93
+ => TemplateRenderer.RenderPartial(testMethodBody.ActTemplateName, testMethodBody.ActTemplateParameters);
20
94
 
21
- protected virtual TestClass CreateTestClass() => TestClassGenerator.Create(this);
95
+ protected virtual string RenderTestMethodBodyAssert(TestMethodBody testMethodBody)
96
+ => TemplateRenderer.RenderPartial(testMethodBody.AssertTemplateName, testMethodBody.AssertTemplateParameters);
22
97
  }
23
- }
98
+ }