trackler 2.0.8.24 → 2.0.8.26

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/lib/trackler/version.rb +1 -1
  3. data/tracks/c/config.json +9 -0
  4. data/tracks/c/exercises/nucleotide-count/makefile +15 -0
  5. data/tracks/c/exercises/nucleotide-count/src/example.c +43 -0
  6. data/tracks/c/exercises/nucleotide-count/src/example.h +6 -0
  7. data/tracks/c/exercises/nucleotide-count/test/test_nucleotide_count.c +58 -0
  8. data/tracks/c/exercises/nucleotide-count/test/vendor/unity.c +1300 -0
  9. data/tracks/c/exercises/nucleotide-count/test/vendor/unity.h +274 -0
  10. data/tracks/c/exercises/nucleotide-count/test/vendor/unity_internals.h +701 -0
  11. data/tracks/ceylon/README.md +2 -2
  12. data/tracks/csharp/.gitattributes +11 -0
  13. data/tracks/csharp/appveyor.yml +1 -4
  14. data/tracks/csharp/exercises/acronym/AcronymTest.cs +1 -1
  15. data/tracks/csharp/exercises/atbash-cipher/AtbashCipher.cs +8 -3
  16. data/tracks/csharp/exercises/atbash-cipher/AtbashCipherTest.cs +76 -0
  17. data/tracks/csharp/exercises/atbash-cipher/Example.cs +22 -23
  18. data/tracks/csharp/exercises/isogram/Example.cs +2 -2
  19. data/tracks/csharp/exercises/isogram/IsogramTest.cs +47 -15
  20. data/tracks/csharp/exercises/nth-prime/Example.cs +4 -1
  21. data/tracks/csharp/exercises/nth-prime/NthPrime.cs +1 -1
  22. data/tracks/csharp/exercises/nth-prime/NthPrimeTest.cs +29 -15
  23. data/tracks/csharp/exercises/perfect-numbers/Example.cs +14 -16
  24. data/tracks/csharp/exercises/perfect-numbers/PerfectNumbers.cs +2 -2
  25. data/tracks/csharp/exercises/perfect-numbers/PerfectNumbersTest.cs +78 -26
  26. data/tracks/csharp/exercises/pig-latin/PigLatinTest.cs +69 -24
  27. data/tracks/csharp/exercises/raindrops/Example.cs +1 -1
  28. data/tracks/csharp/exercises/raindrops/RaindropsTest.cs +93 -31
  29. data/tracks/csharp/exercises/roman-numerals/HINTS.md +2 -0
  30. data/tracks/csharp/exercises/roman-numerals/RomanNumeralsTest.cs +106 -23
  31. data/tracks/csharp/exercises/word-search/HINTS.md +6 -0
  32. data/tracks/csharp/generators/{TestClass.cs → Classes/TestClass.cs} +2 -1
  33. data/tracks/csharp/generators/{TestClassNameTransformer.cs → Classes/TestClassNameTransformer.cs} +1 -1
  34. data/tracks/csharp/generators/{TestClassRenderer.cs → Classes/TestClassRenderer.cs} +2 -1
  35. data/tracks/csharp/generators/Classes/TestedClassNameTransformer.cs +9 -0
  36. data/tracks/csharp/generators/{CanonicalData.cs → Data/CanonicalData.cs} +1 -1
  37. data/tracks/csharp/generators/{CanonicalDataCase.cs → Data/CanonicalDataCase.cs} +3 -3
  38. data/tracks/csharp/generators/{CanonicalDataCaseJsonConverter.cs → Data/CanonicalDataCaseJsonConverter.cs} +1 -1
  39. data/tracks/csharp/generators/{CanonicalDataCasesJsonConverter.cs → Data/CanonicalDataCasesJsonConverter.cs} +2 -2
  40. data/tracks/csharp/generators/{CanonicalDataParser.cs → Data/CanonicalDataParser.cs} +5 -5
  41. data/tracks/csharp/generators/{ExerciseCollection.cs → Data/ExerciseCollection.cs} +3 -3
  42. data/tracks/csharp/generators/Exercises/AcronymExercise.cs +20 -0
  43. data/tracks/csharp/generators/Exercises/AtbashCipherExercise.cs +20 -0
  44. data/tracks/csharp/generators/Exercises/BooleanExercise.cs +14 -0
  45. data/tracks/csharp/generators/Exercises/EqualityExercise.cs +14 -0
  46. data/tracks/csharp/generators/Exercises/Exercise.cs +59 -4
  47. data/tracks/csharp/generators/Exercises/IsogramExercise.cs +9 -0
  48. data/tracks/csharp/generators/Exercises/LeapExercise.cs +1 -4
  49. data/tracks/csharp/generators/Exercises/NthPrimeExercise.cs +25 -0
  50. data/tracks/csharp/generators/Exercises/PerfectNumbersExercise.cs +29 -0
  51. data/tracks/csharp/generators/Exercises/PigLatinExercise.cs +9 -0
  52. data/tracks/csharp/generators/Exercises/RaindropsExercise.cs +20 -0
  53. data/tracks/csharp/generators/Exercises/RomanNumeralsExercise.cs +30 -0
  54. data/tracks/csharp/generators/Helpers/StringExtensions.cs +8 -0
  55. data/tracks/csharp/generators/{To.cs → Helpers/To.cs} +4 -1
  56. data/tracks/csharp/generators/Methods/BooleanTestMethodGenerator.cs +32 -0
  57. data/tracks/csharp/generators/Methods/EqualityTestMethodGenerator.cs +25 -0
  58. data/tracks/csharp/generators/Methods/ExceptionTestMethodGenerator.cs +30 -0
  59. data/tracks/csharp/generators/{TestMethod.cs → Methods/TestMethod.cs} +6 -3
  60. data/tracks/csharp/generators/Methods/TestMethodData.cs +12 -0
  61. data/tracks/csharp/generators/Methods/TestMethodGenerator.cs +64 -0
  62. data/tracks/csharp/generators/Methods/TestMethodNameTransformer.cs +23 -0
  63. data/tracks/csharp/generators/Methods/TestMethodOptions.cs +13 -0
  64. data/tracks/csharp/generators/{TestMethodRenderer.cs → Methods/TestMethodRenderer.cs} +1 -1
  65. data/tracks/csharp/generators/{TestedMethodNameTransformer.cs → Methods/TestedMethodNameTransformer.cs} +1 -1
  66. data/tracks/csharp/generators/Methods/TestedMethodType.cs +9 -0
  67. data/tracks/csharp/generators/Program.cs +2 -0
  68. data/tracks/elixir/config.json +7 -0
  69. data/tracks/elixir/exercises/diffie-hellman/HINTS.md +10 -0
  70. data/tracks/elixir/exercises/diffie-hellman/diffie_hellman.exs +61 -0
  71. data/tracks/elixir/exercises/diffie-hellman/diffie_hellman_test.exs +99 -0
  72. data/tracks/elixir/exercises/diffie-hellman/example.exs +64 -0
  73. data/tracks/haskell/exercises/pov/src/POV.hs +2 -2
  74. data/tracks/haskell/exercises/pythagorean-triplet/src/Triplet.hs +6 -3
  75. data/tracks/haskell/exercises/queen-attack/src/Queens.hs +1 -1
  76. data/tracks/haskell/exercises/raindrops/src/Raindrops.hs +2 -1
  77. data/tracks/haskell/exercises/robot-name/src/Robot.hs +2 -2
  78. data/tracks/haskell/exercises/robot-simulator/src/Robot.hs +6 -6
  79. data/tracks/haskell/exercises/roman-numerals/src/Roman.hs +2 -1
  80. data/tracks/haskell/exercises/run-length-encoding/src/RunLength.hs +2 -2
  81. data/tracks/haskell/exercises/saddle-points/src/Matrix.hs +2 -1
  82. data/tracks/haskell/exercises/say/src/Say.hs +2 -1
  83. data/tracks/haskell/exercises/scrabble-score/src/Scrabble.hs +4 -2
  84. data/tracks/haskell/exercises/secret-handshake/src/SecretHandshake.hs +1 -1
  85. data/tracks/haskell/exercises/sgf-parsing/src/Sgf.hs +1 -1
  86. data/tracks/java/exercises/acronym/src/example/java/Acronym.java +11 -1
  87. data/tracks/java/exercises/acronym/src/test/java/AcronymTest.java +8 -9
  88. data/tracks/java/exercises/grade-school/src/test/java/SchoolTest.java +8 -2
  89. data/tracks/java/exercises/luhn/src/test/java/LuhnValidatorTest.java +20 -13
  90. data/tracks/java/exercises/robot-name/src/test/java/RobotTest.java +6 -1
  91. data/tracks/javascript/README.md +1 -1
  92. data/tracks/javascript/docs/TESTS.md +9 -1
  93. data/tracks/kotlin/exercises/luhn/src/example/kotlin/Luhn.kt +18 -26
  94. data/tracks/kotlin/exercises/luhn/src/test/kotlin/LuhnTest.kt +40 -38
  95. data/tracks/php/README.md +1 -1
  96. data/tracks/php/config.json +5 -0
  97. data/tracks/php/exercises/perfect-numbers/example.php +23 -0
  98. data/tracks/php/exercises/perfect-numbers/perfect-numbers_test.php +99 -0
  99. data/tracks/purescript/.travis.yml +1 -0
  100. data/tracks/purescript/bin/test.sh +33 -8
  101. data/tracks/purescript/config.json +7 -0
  102. data/tracks/purescript/exercises/meetup/bower.json +17 -0
  103. data/tracks/purescript/exercises/meetup/examples/src/Meetup.purs +37 -0
  104. data/tracks/purescript/exercises/meetup/src/Meetup.purs +11 -0
  105. data/tracks/purescript/exercises/meetup/test/Main.purs +395 -0
  106. data/tracks/python/README.md +7 -6
  107. data/tracks/python/docs/TOOLS.md +3 -3
  108. data/tracks/python/exercises/bracket-push/bracket_push_test.py +32 -15
  109. data/tracks/python/exercises/hamming/hamming_test.py +2 -0
  110. data/tracks/python/exercises/luhn/luhn_test.py +2 -0
  111. data/tracks/python/test/check-exercises.py +7 -1
  112. metadata +56 -20
  113. data/tracks/csharp/exercises/atbash-cipher/AtbashTest.cs +0 -17
  114. data/tracks/csharp/generators/BooleanTestMethod.cs +0 -36
  115. data/tracks/csharp/generators/TestMethodNameTransformer.cs +0 -11
  116. data/tracks/csharp/generators/TestedClassNameTransformer.cs +0 -11
  117. data/tracks/java/exercises/allergies/src/main/java/.keep +0 -0
@@ -1,9 +1,9 @@
1
1
  # xceylon
2
2
 
3
- Exercism problems in Ceylon.
4
-
5
3
  [![Build Status](https://travis-ci.org/exercism/xceylon.svg?branch=master)](https://travis-ci.org/exercism/xceylon)
6
4
 
5
+ Exercism problems in Ceylon.
6
+
7
7
  ## Contributing Guide
8
8
 
9
9
  ### Asking for help
@@ -0,0 +1,11 @@
1
+ * text=auto
2
+
3
+ *.cs text=auto diff=csharp
4
+ *.csproj text=auto
5
+ *.sln text=auto eol=crlf
6
+ *.sh eol=lf
7
+ *.ps1 eol=crlf
8
+
9
+ *.jpg binary
10
+ *.png binary
11
+ *.gif binary
@@ -1,7 +1,4 @@
1
1
  image: Visual Studio 2017
2
- environment:
3
- DOTNET_CLI_TELEMETRY_OPTOUT: true
4
- DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
5
2
  test: off
6
3
  build_script:
7
- - ps: ./build.ps1
4
+ - ps: ./build.ps1
@@ -33,7 +33,7 @@ public class AcronymTest
33
33
  }
34
34
 
35
35
  [Fact(Skip = "Remove to run test")]
36
- public void NonAcronymAllCapsWord()
36
+ public void Non_acronym_all_caps_word()
37
37
  {
38
38
  Assert.Equal("GIMP", Acronym.Abbreviate("GNU Image Manipulation Program"));
39
39
  }
@@ -1,9 +1,14 @@
1
1
  using System;
2
2
 
3
- public static class Atbash
3
+ public static class AtbashCipher
4
4
  {
5
- public static string Encode(string value)
5
+ public static string Encode(string plainValue)
6
6
  {
7
7
  throw new NotImplementedException("You need to implement this function.");
8
8
  }
9
- }
9
+
10
+ public static string Decode(string encodedValue)
11
+ {
12
+ throw new NotImplementedException("You need to implement this function.");
13
+ }
14
+ }
@@ -0,0 +1,76 @@
1
+ using Xunit;
2
+
3
+ public class AtbashCipherTest
4
+ {
5
+ [Fact]
6
+ public void Encode_yes()
7
+ {
8
+ Assert.Equal("bvh", AtbashCipher.Encode("yes"));
9
+ }
10
+
11
+ [Fact(Skip = "Remove to run test")]
12
+ public void Encode_no()
13
+ {
14
+ Assert.Equal("ml", AtbashCipher.Encode("no"));
15
+ }
16
+
17
+ [Fact(Skip = "Remove to run test")]
18
+ public void Encode_omg()
19
+ {
20
+ Assert.Equal("lnt", AtbashCipher.Encode("OMG"));
21
+ }
22
+
23
+ [Fact(Skip = "Remove to run test")]
24
+ public void Encode_spaces()
25
+ {
26
+ Assert.Equal("lnt", AtbashCipher.Encode("O M G"));
27
+ }
28
+
29
+ [Fact(Skip = "Remove to run test")]
30
+ public void Encode_mindblowingly()
31
+ {
32
+ Assert.Equal("nrmwy oldrm tob", AtbashCipher.Encode("mindblowingly"));
33
+ }
34
+
35
+ [Fact(Skip = "Remove to run test")]
36
+ public void Encode_numbers()
37
+ {
38
+ Assert.Equal("gvhgr mt123 gvhgr mt", AtbashCipher.Encode("Testing,1 2 3, testing."));
39
+ }
40
+
41
+ [Fact(Skip = "Remove to run test")]
42
+ public void Encode_deep_thought()
43
+ {
44
+ Assert.Equal("gifgs rhurx grlm", AtbashCipher.Encode("Truth is fiction."));
45
+ }
46
+
47
+ [Fact(Skip = "Remove to run test")]
48
+ public void Encode_all_the_letters()
49
+ {
50
+ Assert.Equal("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", AtbashCipher.Encode("The quick brown fox jumps over the lazy dog."));
51
+ }
52
+
53
+ [Fact(Skip = "Remove to run test")]
54
+ public void Decode_exercism()
55
+ {
56
+ Assert.Equal("exercism", AtbashCipher.Decode("vcvix rhn"));
57
+ }
58
+
59
+ [Fact(Skip = "Remove to run test")]
60
+ public void Decode_a_sentence()
61
+ {
62
+ Assert.Equal("anobstacleisoftenasteppingstone", AtbashCipher.Decode("zmlyh gzxov rhlug vmzhg vkkrm thglm v"));
63
+ }
64
+
65
+ [Fact(Skip = "Remove to run test")]
66
+ public void Decode_numbers()
67
+ {
68
+ Assert.Equal("testing123testing", AtbashCipher.Decode("gvhgr mt123 gvhgr mt"));
69
+ }
70
+
71
+ [Fact(Skip = "Remove to run test")]
72
+ public void Decode_all_the_letters()
73
+ {
74
+ Assert.Equal("thequickbrownfoxjumpsoverthelazydog", AtbashCipher.Decode("gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt"));
75
+ }
76
+ }
@@ -1,35 +1,34 @@
1
+ using System;
1
2
  using System.Collections.Generic;
2
3
  using System.Linq;
3
4
 
4
- public static class Atbash
5
+ public static class AtbashCipher
5
6
  {
6
- private const string PLAIN = "abcdefghijklmnopqrstuvwxyz";
7
- private const string CIPHER = "zyxwvutsrqponmlkjihgfedcba";
7
+ private const int BlockSize = 5;
8
+ private const string Plain = "abcdefghijklmnopqrstuvwxyz0123456789";
9
+ private const string Cipher = "zyxwvutsrqponmlkjihgfedcba0123456789";
8
10
 
9
- public static string Encode(string value)
10
- {
11
- var encoded = string.Concat(StripInvalidCharacters(value).ToLower().Select(ApplyCipher));
12
- return SplitIntoFiveLetterWords(encoded);
13
- }
11
+ public static string Encode(string plainValue)
12
+ => string.Join(" ", EncodeInBlocks(GetEncodedCharacters(plainValue)));
14
13
 
15
- private static string StripInvalidCharacters(string value)
16
- {
17
- return string.Concat(value.Where(char.IsLetterOrDigit));
18
- }
14
+ public static string Decode(string encodedValue)
15
+ => new string(encodedValue.Replace(" ", "").Select(Decode).ToArray());
19
16
 
20
- private static char ApplyCipher(char value)
21
- {
22
- var idx = PLAIN.IndexOf(value);
23
- return idx >= 0 ? CIPHER[idx] : value;
24
- }
17
+ private static IEnumerable<char> GetEncodedCharacters(string words)
18
+ => GetValidCharacters(words).Select(Encode);
25
19
 
26
- private static string SplitIntoFiveLetterWords(string value)
27
- {
28
- var words = new List<string>();
20
+ private static IEnumerable<char> GetValidCharacters(string words)
21
+ => words.ToLowerInvariant().Where(char.IsLetterOrDigit);
22
+
23
+ private static char Encode(char c) => Cipher[Plain.IndexOf(c)];
29
24
 
30
- for (int i = 0; i < value.Length; i += 5)
31
- words.Add(i + 5 <= value.Length ? value.Substring(i, 5) : value.Substring(i));
25
+ private static char Decode(char c) => Plain[Cipher.IndexOf(c)];
26
+
27
+ private static IEnumerable<string> EncodeInBlocks(IEnumerable<char> value)
28
+ {
29
+ var valueAsString = new string(value.ToArray());
32
30
 
33
- return string.Join(" ", words);
31
+ for (var i = 0; i < valueAsString.Length; i += BlockSize)
32
+ yield return valueAsString.Substring(i, Math.Min(BlockSize, valueAsString.Length - i));
34
33
  }
35
34
  }
@@ -1,7 +1,7 @@
1
1
  using System;
2
2
  using System.Collections.Generic;
3
3
 
4
- public class Isogram
4
+ public static class Isogram
5
5
  {
6
6
  public static bool IsIsogram(string word)
7
7
  {
@@ -17,4 +17,4 @@ public class Isogram
17
17
 
18
18
  return true;
19
19
  }
20
- }
20
+ }
@@ -1,20 +1,52 @@
1
- using Xunit;
1
+ using Xunit;
2
2
 
3
3
  public class IsogramTest
4
4
  {
5
- [Theory]
6
- [InlineData("duplicates", true)]
7
- [InlineData("eleven", false)]
8
- [InlineData("subdermatoglyphic", true)]
9
- [InlineData("Alphabet", false)]
10
- [InlineData("thumbscrew-japingly", true)]
11
- [InlineData("Hjelmqvist-Gryb-Zock-Pfund-Wax", true)]
12
- [InlineData("Heizölrückstoßabdämpfung", true)]
13
- [InlineData("the quick brown fox", false)]
14
- [InlineData("Emily Jung Schwartzkopf", true)]
15
- [InlineData("éléphant", false)]
16
- public void Isogram_correctly_detects_isograms(string input, bool expected)
17
- {
18
- Assert.Equal(expected, Isogram.IsIsogram(input));
5
+ [Fact]
6
+ public void Empty_string()
7
+ {
8
+ Assert.True(Isogram.IsIsogram(""));
9
+ }
10
+
11
+ [Fact(Skip = "Remove to run test")]
12
+ public void Isogram_with_only_lower_case_characters()
13
+ {
14
+ Assert.True(Isogram.IsIsogram("isogram"));
15
+ }
16
+
17
+ [Fact(Skip = "Remove to run test")]
18
+ public void Word_with_one_duplicated_character()
19
+ {
20
+ Assert.False(Isogram.IsIsogram("eleven"));
21
+ }
22
+
23
+ [Fact(Skip = "Remove to run test")]
24
+ public void Longest_reported_english_isogram()
25
+ {
26
+ Assert.True(Isogram.IsIsogram("subdermatoglyphic"));
27
+ }
28
+
29
+ [Fact(Skip = "Remove to run test")]
30
+ public void Word_with_duplicated_character_in_mixed_case()
31
+ {
32
+ Assert.False(Isogram.IsIsogram("Alphabet"));
33
+ }
34
+
35
+ [Fact(Skip = "Remove to run test")]
36
+ public void Hypothetical_isogrammic_word_with_hyphen()
37
+ {
38
+ Assert.True(Isogram.IsIsogram("thumbscrew-japingly"));
39
+ }
40
+
41
+ [Fact(Skip = "Remove to run test")]
42
+ public void Isogram_with_duplicated_non_letter_character()
43
+ {
44
+ Assert.True(Isogram.IsIsogram("Hjelmqvist-Gryb-Zock-Pfund-Wax"));
45
+ }
46
+
47
+ [Fact(Skip = "Remove to run test")]
48
+ public void Made_up_name_that_is_an_isogram()
49
+ {
50
+ Assert.True(Isogram.IsIsogram("Emily Jung Schwartzkopf"));
19
51
  }
20
52
  }
@@ -4,8 +4,11 @@ using System.Linq;
4
4
 
5
5
  public static class NthPrime
6
6
  {
7
- public static int Nth(int nth)
7
+ public static int Prime(int nth)
8
8
  {
9
+ if (nth < 1)
10
+ throw new ArgumentOutOfRangeException();
11
+
9
12
  return Primes().Skip(nth - 1).First();
10
13
  }
11
14
 
@@ -4,7 +4,7 @@ using System.Linq;
4
4
 
5
5
  public static class NthPrime
6
6
  {
7
- public static int Nth(int nth)
7
+ public static int Prime(int nth)
8
8
  {
9
9
  throw new NotImplementedException("You need to implement this function.");
10
10
  }
@@ -1,21 +1,35 @@
1
- using Xunit;
1
+ using Xunit;
2
+ using System;
2
3
 
3
4
  public class NthPrimeTest
4
5
  {
5
- [Theory]
6
- [InlineData(1, 2)]
7
- [InlineData(2, 3)]
8
- [InlineData(3, 5)]
9
- [InlineData(4, 7)]
10
- [InlineData(5, 11)]
11
- [InlineData(6, 13)]
12
- [InlineData(7, 17)]
13
- [InlineData(8, 19)]
14
- [InlineData(1000, 7919)]
15
- [InlineData(10000, 104729)]
16
- [InlineData(10001, 104743)]
17
- public void Nth_prime_calculated(int nth, int expected)
6
+ [Fact]
7
+ public void First_prime()
18
8
  {
19
- Assert.Equal(expected, NthPrime.Nth(nth));
9
+ Assert.Equal(2, NthPrime.Prime(1));
10
+ }
11
+
12
+ [Fact(Skip = "Remove to run test")]
13
+ public void Second_prime()
14
+ {
15
+ Assert.Equal(3, NthPrime.Prime(2));
16
+ }
17
+
18
+ [Fact(Skip = "Remove to run test")]
19
+ public void Sixth_prime()
20
+ {
21
+ Assert.Equal(13, NthPrime.Prime(6));
22
+ }
23
+
24
+ [Fact(Skip = "Remove to run test")]
25
+ public void Big_prime()
26
+ {
27
+ Assert.Equal(104743, NthPrime.Prime(10001));
28
+ }
29
+
30
+ [Fact(Skip = "Remove to run test")]
31
+ public void There_is_no_zeroth_prime()
32
+ {
33
+ Assert.Throws<ArgumentOutOfRangeException>(() => NthPrime.Prime(0));
20
34
  }
21
35
  }
@@ -1,35 +1,33 @@
1
- public enum NumberType
1
+ using System;
2
+
3
+ public enum Classification
2
4
  {
3
5
  Perfect,
4
6
  Abundant,
5
7
  Deficient
6
8
  }
7
9
 
8
- public class PerfectNumbers
10
+ public static class PerfectNumbers
9
11
  {
10
- public static NumberType Classify(int number)
12
+ public static Classification Classify(int number)
11
13
  {
14
+ if (number < 1)
15
+ throw new ArgumentOutOfRangeException();
16
+
12
17
  int sumOfFactors = 0;
13
18
 
14
19
  for (int i = 1; i < number; i++)
15
20
  {
16
21
  if (number % i == 0)
17
- {
18
22
  sumOfFactors += i;
19
- }
20
23
  }
21
24
 
22
25
  if (sumOfFactors < number)
23
- {
24
- return NumberType.Deficient;
25
- }
26
- else if (sumOfFactors == number)
27
- {
28
- return NumberType.Perfect;
29
- }
30
- else
31
- {
32
- return NumberType.Abundant;
33
- }
26
+ return Classification.Deficient;
27
+
28
+ if (sumOfFactors == number)
29
+ return Classification.Perfect;
30
+
31
+ return Classification.Abundant;
34
32
  }
35
33
  }
@@ -1,6 +1,6 @@
1
1
  using System;
2
2
 
3
- public enum NumberType
3
+ public enum Classification
4
4
  {
5
5
  Perfect,
6
6
  Abundant,
@@ -9,7 +9,7 @@ public enum NumberType
9
9
 
10
10
  public static class PerfectNumbers
11
11
  {
12
- public static NumberType Classify(int number)
12
+ public static Classification Classify(int number)
13
13
  {
14
14
  throw new NotImplementedException();
15
15
  }
@@ -1,31 +1,83 @@
1
- using Xunit;
1
+ using Xunit;
2
+ using System;
2
3
 
3
4
  public class PerfectNumbersTest
4
5
  {
5
- [Theory]
6
- [InlineData(3)]
7
- [InlineData(7)]
8
- [InlineData(13)]
9
- public void Can_classify_deficient_numbers(int number)
10
- {
11
- Assert.Equal(NumberType.Deficient, PerfectNumbers.Classify(number));
12
- }
13
-
14
- [Theory(Skip = "Remove to run test")]
15
- [InlineData(6)]
16
- [InlineData(28)]
17
- [InlineData(496)]
18
- public void Can_classify_perfect_numbers(int number)
19
- {
20
- Assert.Equal(NumberType.Perfect, PerfectNumbers.Classify(number));
21
- }
22
-
23
- [Theory(Skip = "Remove to run test")]
24
- [InlineData(12)]
25
- [InlineData(18)]
26
- [InlineData(20)]
27
- public void Can_classify_abundant_numbers(int number)
28
- {
29
- Assert.Equal(NumberType.Abundant, PerfectNumbers.Classify(number));
6
+ [Fact]
7
+ public void Smallest_perfect_number_is_classified_correctly()
8
+ {
9
+ Assert.Equal(Classification.Perfect, PerfectNumbers.Classify(6));
10
+ }
11
+
12
+ [Fact(Skip = "Remove to run test")]
13
+ public void Medium_perfect_number_is_classified_correctly()
14
+ {
15
+ Assert.Equal(Classification.Perfect, PerfectNumbers.Classify(28));
16
+ }
17
+
18
+ [Fact(Skip = "Remove to run test")]
19
+ public void Large_perfect_number_is_classified_correctly()
20
+ {
21
+ Assert.Equal(Classification.Perfect, PerfectNumbers.Classify(33550336));
22
+ }
23
+
24
+ [Fact(Skip = "Remove to run test")]
25
+ public void Smallest_abundant_number_is_classified_correctly()
26
+ {
27
+ Assert.Equal(Classification.Abundant, PerfectNumbers.Classify(12));
28
+ }
29
+
30
+ [Fact(Skip = "Remove to run test")]
31
+ public void Medium_abundant_number_is_classified_correctly()
32
+ {
33
+ Assert.Equal(Classification.Abundant, PerfectNumbers.Classify(30));
34
+ }
35
+
36
+ [Fact(Skip = "Remove to run test")]
37
+ public void Large_abundant_number_is_classified_correctly()
38
+ {
39
+ Assert.Equal(Classification.Abundant, PerfectNumbers.Classify(33550335));
40
+ }
41
+
42
+ [Fact(Skip = "Remove to run test")]
43
+ public void Smallest_prime_deficient_number_is_classified_correctly()
44
+ {
45
+ Assert.Equal(Classification.Deficient, PerfectNumbers.Classify(2));
46
+ }
47
+
48
+ [Fact(Skip = "Remove to run test")]
49
+ public void Smallest_non_prime_deficient_number_is_classified_correctly()
50
+ {
51
+ Assert.Equal(Classification.Deficient, PerfectNumbers.Classify(4));
52
+ }
53
+
54
+ [Fact(Skip = "Remove to run test")]
55
+ public void Medium_deficient_number_is_classified_correctly()
56
+ {
57
+ Assert.Equal(Classification.Deficient, PerfectNumbers.Classify(32));
58
+ }
59
+
60
+ [Fact(Skip = "Remove to run test")]
61
+ public void Large_deficient_number_is_classified_correctly()
62
+ {
63
+ Assert.Equal(Classification.Deficient, PerfectNumbers.Classify(33550337));
64
+ }
65
+
66
+ [Fact(Skip = "Remove to run test")]
67
+ public void Edge_case_no_factors_other_than_itself_is_classified_correctly()
68
+ {
69
+ Assert.Equal(Classification.Deficient, PerfectNumbers.Classify(1));
70
+ }
71
+
72
+ [Fact(Skip = "Remove to run test")]
73
+ public void Zero_is_rejected_not_a_natural_number_()
74
+ {
75
+ Assert.Throws<ArgumentOutOfRangeException>(() => PerfectNumbers.Classify(0));
76
+ }
77
+
78
+ [Fact(Skip = "Remove to run test")]
79
+ public void Negative_integer_is_rejected_not_a_natural_number_()
80
+ {
81
+ Assert.Throws<ArgumentOutOfRangeException>(() => PerfectNumbers.Classify(-1));
30
82
  }
31
83
  }