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,50 +1,23 @@
1
+ using System.Linq;
1
2
  using System.Text.RegularExpressions;
2
3
 
3
4
  public class PhoneNumber
4
5
  {
5
- private static readonly Regex DigitsOnly = new Regex(@"[^\d]");
6
+ private static readonly Regex phoneNumberFormat = new Regex("^1?([2-9][0-9]{2}[2-9][0-9]{6})$");
6
7
 
7
- public string Number { get; private set; }
8
- public string AreaCode { get; private set; }
9
-
10
- public PhoneNumber(string phoneNumber)
11
- {
12
- Number = GetValidatedPhoneNumber(phoneNumber);
13
- AreaCode = Number.Substring(0, 3);
14
- }
15
-
16
- private static string GetValidatedPhoneNumber(string phoneNumber)
17
- {
18
- var stripped = StripOutNonNumerics(phoneNumber);
19
-
20
- if (IsInvalidPhoneNumber(stripped))
21
- return GetInvalidPhoneNumberReplacement(stripped);
22
-
23
- return stripped;
24
- }
25
-
26
- private static string StripOutNonNumerics(string value)
27
- {
28
- return DigitsOnly.Replace(value, "");
29
- }
30
-
31
- private static bool IsInvalidPhoneNumber(string phoneNumber)
32
- {
33
- return phoneNumber.Length != 10;
34
- }
35
-
36
- private static string GetInvalidPhoneNumberReplacement(string phoneNumber)
37
- {
38
- return IsPhoneNumberWithUSAreaCode(phoneNumber) ? phoneNumber.Substring(1) : "0000000000";
39
- }
40
-
41
- private static bool IsPhoneNumberWithUSAreaCode(string value)
42
- {
43
- return value.Length == 11 && value.StartsWith("1");
44
- }
45
-
46
- public override string ToString()
8
+ public static string Clean(string phoneNumber)
47
9
  {
48
- return string.Format("({0}) {1}-{2}", AreaCode, Number.Substring(3, 3), Number.Substring(6));
10
+ var digits = string.Join(string.Empty, phoneNumber.Where(l => l >= '0' && l <= '9'));
11
+
12
+ var match = phoneNumberFormat.Match(digits);
13
+
14
+ if (match.Success)
15
+ {
16
+ return match.Groups[1].ToString();
17
+ }
18
+ else
19
+ {
20
+ return null;
21
+ }
49
22
  }
50
23
  }
@@ -2,23 +2,8 @@
2
2
 
3
3
  public class PhoneNumber
4
4
  {
5
- public PhoneNumber(string phoneNumber)
5
+ public static string Clean(string phoneNumber)
6
6
  {
7
- }
8
-
9
- public string Number
10
- {
11
- get
12
- {
13
- throw new NotImplementedException("You need to implement this function.");
14
- }
15
- }
16
-
17
- public string AreaCode
18
- {
19
- get
20
- {
21
- throw new NotImplementedException("You need to implement this function.");
22
- }
7
+ throw new NotImplementedException("You need to implement this function.");
23
8
  }
24
9
  }
@@ -1,53 +1,90 @@
1
+ // This file was auto-generated based on version 1.2.0 of the canonical data.
2
+
1
3
  using Xunit;
2
4
 
3
5
  public class PhoneNumberTest
4
6
  {
5
7
  [Fact]
6
- public void Cleans_parens_spaces_and_dashes()
8
+ public void Cleans_the_number()
7
9
  {
8
- var phone = new PhoneNumber("(123) 456-7890");
9
- Assert.Equal("1234567890", phone.Number);
10
+ var phrase = "(223) 456-7890";
11
+ Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
10
12
  }
11
13
 
12
14
  [Fact(Skip = "Remove to run test")]
13
15
  public void Cleans_numbers_with_dots()
14
16
  {
15
- var phone = new PhoneNumber("123.456.7890");
16
- Assert.Equal("1234567890", phone.Number);
17
+ var phrase = "223.456.7890";
18
+ Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
17
19
  }
18
20
 
19
21
  [Fact(Skip = "Remove to run test")]
20
- public void Allows_us_country_code()
22
+ public void Cleans_numbers_with_multiple_spaces()
21
23
  {
22
- var phone = new PhoneNumber("11234567890");
23
- Assert.Equal("1234567890", phone.Number);
24
+ var phrase = "223 456 7890 ";
25
+ Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
24
26
  }
25
27
 
26
28
  [Fact(Skip = "Remove to run test")]
27
- public void Invalid_when_11_digits()
29
+ public void Invalid_when_9_digits()
28
30
  {
29
- var phone = new PhoneNumber("21234567890");
30
- Assert.Equal("0000000000", phone.Number);
31
+ var phrase = "123456789";
32
+ Assert.Null(PhoneNumber.Clean(phrase));
31
33
  }
32
34
 
33
35
  [Fact(Skip = "Remove to run test")]
34
- public void Invalid_when_9_digits()
36
+ public void Invalid_when_11_digits_does_not_start_with_a_1()
37
+ {
38
+ var phrase = "22234567890";
39
+ Assert.Null(PhoneNumber.Clean(phrase));
40
+ }
41
+
42
+ [Fact(Skip = "Remove to run test")]
43
+ public void Valid_when_11_digits_and_starting_with_1()
44
+ {
45
+ var phrase = "12234567890";
46
+ Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
47
+ }
48
+
49
+ [Fact(Skip = "Remove to run test")]
50
+ public void Valid_when_11_digits_and_starting_with_1_even_with_punctuation()
51
+ {
52
+ var phrase = "+1 (223) 456-7890";
53
+ Assert.Equal("2234567890", PhoneNumber.Clean(phrase));
54
+ }
55
+
56
+ [Fact(Skip = "Remove to run test")]
57
+ public void Invalid_when_more_than_11_digits()
58
+ {
59
+ var phrase = "321234567890";
60
+ Assert.Null(PhoneNumber.Clean(phrase));
61
+ }
62
+
63
+ [Fact(Skip = "Remove to run test")]
64
+ public void Invalid_with_letters()
65
+ {
66
+ var phrase = "123-abc-7890";
67
+ Assert.Null(PhoneNumber.Clean(phrase));
68
+ }
69
+
70
+ [Fact(Skip = "Remove to run test")]
71
+ public void Invalid_with_punctuations()
35
72
  {
36
- var phone = new PhoneNumber("123456789");
37
- Assert.Equal("0000000000", phone.Number);
73
+ var phrase = "123-@:!-7890";
74
+ Assert.Null(PhoneNumber.Clean(phrase));
38
75
  }
39
76
 
40
77
  [Fact(Skip = "Remove to run test")]
41
- public void Has_an_area_code()
78
+ public void Invalid_if_area_code_does_not_start_with_2_9()
42
79
  {
43
- var phone = new PhoneNumber("1234567890");
44
- Assert.Equal("123", phone.AreaCode);
80
+ var phrase = "(123) 456-7890";
81
+ Assert.Null(PhoneNumber.Clean(phrase));
45
82
  }
46
83
 
47
84
  [Fact(Skip = "Remove to run test")]
48
- public void Formats_a_number()
85
+ public void Invalid_if_exchange_code_does_not_start_with_2_9()
49
86
  {
50
- var phone = new PhoneNumber("1234567890");
51
- Assert.Equal("(123) 456-7890", phone.ToString());
87
+ var phrase = "(223) 056-7890";
88
+ Assert.Null(PhoneNumber.Clean(phrase));
52
89
  }
53
90
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  public class PrimeFactors
4
4
  {
5
- public static int[] For(long number)
5
+ public static int[] Factors(long number)
6
6
  {
7
7
  var primes = new List<int>();
8
8
  int divisor = 2;
@@ -2,7 +2,7 @@
2
2
 
3
3
  public static class PrimeFactors
4
4
  {
5
- public static int[] For(long number)
5
+ public static int[] Factors(long number)
6
6
  {
7
7
  throw new NotImplementedException();
8
8
  }
@@ -1,70 +1,48 @@
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 PrimeFactorsTest
4
6
  {
5
7
  [Fact]
6
- public void Test_1()
7
- {
8
- Assert.Equal(new int[0], PrimeFactors.For(1));
9
- }
10
-
11
- [Fact(Skip = "Remove to run test")]
12
- public void Test_2()
13
- {
14
- Assert.Equal(new[] { 2 }, PrimeFactors.For(2));
15
- }
16
-
17
- [Fact(Skip = "Remove to run test")]
18
- public void Test_3()
19
- {
20
- Assert.Equal(new[] { 3 }, PrimeFactors.For(3));
21
- }
22
-
23
- [Fact(Skip = "Remove to run test")]
24
- public void Test_4()
25
- {
26
- Assert.Equal(new[] { 2, 2 }, PrimeFactors.For(4));
27
- }
28
-
29
- [Fact(Skip = "Remove to run test")]
30
- public void Test_6()
8
+ public void No_factors()
31
9
  {
32
- Assert.Equal(new[] { 2, 3 }, PrimeFactors.For(6));
10
+ Assert.Empty(PrimeFactors.Factors(1));
33
11
  }
34
12
 
35
13
  [Fact(Skip = "Remove to run test")]
36
- public void Test_8()
14
+ public void Prime_number()
37
15
  {
38
- Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.For(8));
16
+ Assert.Equal(new[] { 2 }, PrimeFactors.Factors(2));
39
17
  }
40
18
 
41
19
  [Fact(Skip = "Remove to run test")]
42
- public void Test_9()
20
+ public void Square_of_a_prime()
43
21
  {
44
- Assert.Equal(new[] { 3, 3 }, PrimeFactors.For(9));
22
+ Assert.Equal(new[] { 3, 3 }, PrimeFactors.Factors(9));
45
23
  }
46
24
 
47
25
  [Fact(Skip = "Remove to run test")]
48
- public void Test_27()
26
+ public void Cube_of_a_prime()
49
27
  {
50
- Assert.Equal(new[] { 3, 3, 3 }, PrimeFactors.For(27));
28
+ Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.Factors(8));
51
29
  }
52
30
 
53
31
  [Fact(Skip = "Remove to run test")]
54
- public void Test_625()
32
+ public void Product_of_primes_and_non_primes()
55
33
  {
56
- Assert.Equal(new[] { 5, 5, 5, 5 }, PrimeFactors.For(625));
34
+ Assert.Equal(new[] { 2, 2, 3 }, PrimeFactors.Factors(12));
57
35
  }
58
36
 
59
37
  [Fact(Skip = "Remove to run test")]
60
- public void Test_901255()
38
+ public void Product_of_primes()
61
39
  {
62
- Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.For(901255));
40
+ Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.Factors(901255));
63
41
  }
64
42
 
65
43
  [Fact(Skip = "Remove to run test")]
66
- public void Test_93819012551()
44
+ public void Factors_include_a_large_prime()
67
45
  {
68
- Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.For(93819012551));
46
+ Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.Factors(93819012551));
69
47
  }
70
48
  }
@@ -1,58 +1,60 @@
1
- using Xunit;
1
+ // This file was auto-generated based on version 1.0.1 of the canonical data.
2
+
3
+ using Xunit;
2
4
 
3
5
  public class RailFenceCipherTest
4
6
  {
5
7
  [Fact]
6
8
  public void Encode_with_two_rails()
7
9
  {
8
- var railFenceCipher = new RailFenceCipher(2);
9
- var actual = railFenceCipher.Encode("XOXOXOXOXOXOXOXOXO");
10
+ var msg = "XOXOXOXOXOXOXOXOXO";
11
+ var sut = new RailFenceCipher(2);
10
12
  var expected = "XXXXXXXXXOOOOOOOOO";
11
- Assert.Equal(expected, actual);
13
+ Assert.Equal(expected, sut.Encode(msg));
12
14
  }
13
15
 
14
16
  [Fact(Skip = "Remove to run test")]
15
17
  public void Encode_with_three_rails()
16
18
  {
17
- var railFenceCipher = new RailFenceCipher(3);
18
- var actual = railFenceCipher.Encode("WEAREDISCOVEREDFLEEATONCE");
19
+ var msg = "WEAREDISCOVEREDFLEEATONCE";
20
+ var sut = new RailFenceCipher(3);
19
21
  var expected = "WECRLTEERDSOEEFEAOCAIVDEN";
20
- Assert.Equal(expected, actual);
22
+ Assert.Equal(expected, sut.Encode(msg));
21
23
  }
22
24
 
23
25
  [Fact(Skip = "Remove to run test")]
24
26
  public void Encode_with_ending_in_the_middle()
25
27
  {
26
- var railFenceCipher = new RailFenceCipher(4);
27
- var actual = railFenceCipher.Encode("EXERCISES");
28
+ var msg = "EXERCISES";
29
+ var sut = new RailFenceCipher(4);
28
30
  var expected = "ESXIEECSR";
29
- Assert.Equal(expected, actual);
31
+ Assert.Equal(expected, sut.Encode(msg));
30
32
  }
31
33
 
32
34
  [Fact(Skip = "Remove to run test")]
33
35
  public void Decode_with_three_rails()
34
36
  {
35
- var railFenceCipher = new RailFenceCipher(3);
36
- var actual = railFenceCipher.Decode("TEITELHDVLSNHDTISEIIEA");
37
+ var msg = "TEITELHDVLSNHDTISEIIEA";
38
+ var sut = new RailFenceCipher(3);
37
39
  var expected = "THEDEVILISINTHEDETAILS";
38
- Assert.Equal(expected, actual);
40
+ Assert.Equal(expected, sut.Decode(msg));
39
41
  }
40
42
 
41
43
  [Fact(Skip = "Remove to run test")]
42
44
  public void Decode_with_five_rails()
43
45
  {
44
- var railFenceCipher = new RailFenceCipher(5);
45
- var actual = railFenceCipher.Decode("EIEXMSMESAORIWSCE");
46
+ var msg = "EIEXMSMESAORIWSCE";
47
+ var sut = new RailFenceCipher(5);
46
48
  var expected = "EXERCISMISAWESOME";
47
- Assert.Equal(expected, actual);
49
+ Assert.Equal(expected, sut.Decode(msg));
48
50
  }
49
51
 
50
52
  [Fact(Skip = "Remove to run test")]
51
53
  public void Decode_with_six_rails()
52
54
  {
53
- var railFenceCipher = new RailFenceCipher(6);
54
- var actual = railFenceCipher.Decode("133714114238148966225439541018335470986172518171757571896261");
55
+ var msg = "133714114238148966225439541018335470986172518171757571896261";
56
+ var sut = new RailFenceCipher(6);
55
57
  var expected = "112358132134558914423337761098715972584418167651094617711286";
56
- Assert.Equal(expected, actual);
58
+ Assert.Equal(expected, sut.Decode(msg));
57
59
  }
58
60
  }
@@ -1,15 +1,20 @@
1
1
  using System.Collections.Generic;
2
2
  using System.Linq;
3
3
 
4
- public class Complement
4
+ public static class RnaTranscription
5
5
  {
6
6
  private static readonly Dictionary<char, char> DnaToRna = new Dictionary<char, char>
7
7
  {
8
8
  { 'G', 'C' }, { 'C', 'G' }, { 'T', 'A' }, { 'A', 'U' }
9
9
  };
10
10
 
11
- public static string OfDna(string nucleotide)
11
+ public static string ToRna(string nucleotide)
12
12
  {
13
+ if (nucleotide.Any(x => !DnaToRna.ContainsKey(x)))
14
+ {
15
+ return null;
16
+ }
17
+
13
18
  return string.Concat(nucleotide.Select(x => DnaToRna[x]));
14
19
  }
15
20
  }
@@ -1,8 +1,8 @@
1
1
  using System;
2
2
 
3
- public static class Complement
3
+ public static class RnaTranscription
4
4
  {
5
- public static string OfDna(string nucleotide)
5
+ public static string ToRna(string nucleotide)
6
6
  {
7
7
  throw new NotImplementedException("You need to implement this function.");
8
8
  }
@@ -1,34 +1,54 @@
1
+ // This file was auto-generated based on version 1.0.1 of the canonical data.
2
+
1
3
  using Xunit;
2
4
 
3
- public class ComplementTest
5
+ public class RnaTranscriptionTest
4
6
  {
5
7
  [Fact]
6
8
  public void Rna_complement_of_cytosine_is_guanine()
7
9
  {
8
- Assert.Equal("G", Complement.OfDna("C"));
10
+ Assert.Equal("G", RnaTranscription.ToRna("C"));
9
11
  }
10
12
 
11
13
  [Fact(Skip = "Remove to run test")]
12
14
  public void Rna_complement_of_guanine_is_cytosine()
13
15
  {
14
- Assert.Equal("C", Complement.OfDna("G"));
16
+ Assert.Equal("C", RnaTranscription.ToRna("G"));
15
17
  }
16
18
 
17
19
  [Fact(Skip = "Remove to run test")]
18
20
  public void Rna_complement_of_thymine_is_adenine()
19
21
  {
20
- Assert.Equal("A", Complement.OfDna("T"));
22
+ Assert.Equal("A", RnaTranscription.ToRna("T"));
21
23
  }
22
24
 
23
25
  [Fact(Skip = "Remove to run test")]
24
26
  public void Rna_complement_of_adenine_is_uracil()
25
27
  {
26
- Assert.Equal("U", Complement.OfDna("A"));
28
+ Assert.Equal("U", RnaTranscription.ToRna("A"));
27
29
  }
28
30
 
29
31
  [Fact(Skip = "Remove to run test")]
30
32
  public void Rna_complement()
31
33
  {
32
- Assert.Equal("UGCACCAGAAUU", Complement.OfDna("ACGTGGTCTTAA"));
34
+ Assert.Equal("UGCACCAGAAUU", RnaTranscription.ToRna("ACGTGGTCTTAA"));
35
+ }
36
+
37
+ [Fact(Skip = "Remove to run test")]
38
+ public void Correctly_handles_invalid_input_rna_instead_of_dna_()
39
+ {
40
+ Assert.Null(RnaTranscription.ToRna("U"));
41
+ }
42
+
43
+ [Fact(Skip = "Remove to run test")]
44
+ public void Correctly_handles_completely_invalid_dna_input()
45
+ {
46
+ Assert.Null(RnaTranscription.ToRna("XXX"));
47
+ }
48
+
49
+ [Fact(Skip = "Remove to run test")]
50
+ public void Correctly_handles_partially_invalid_dna_input()
51
+ {
52
+ Assert.Null(RnaTranscription.ToRna("ACGTXXXCTTAA"));
33
53
  }
34
54
  }