diff --git a/config.json b/config.json index 6de061b080..82f35c0f50 100644 --- a/config.json +++ b/config.json @@ -80,8 +80,7 @@ "unlocked_by": null, "difficulty": 1, "topics": [ - "lists", - "strings" + "lists" ] }, { @@ -1390,4 +1389,4 @@ ] } ] -} +} \ No newline at end of file diff --git a/exercises/darts/DartsTest.cs b/exercises/darts/DartsTest.cs index c5af8c904b..3cfbbbec96 100644 --- a/exercises/darts/DartsTest.cs +++ b/exercises/darts/DartsTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.0.0 of the canonical data. +// This file was auto-generated based on version 1.1.0 of the canonical data. using Xunit; @@ -7,30 +7,42 @@ public class DartsTest [Fact] public void A_dart_lands_outside_the_target() { - Assert.Equal(0, Darts.Score(15.3, 13.2)); + Assert.Equal(0, Darts.Score(-9, 9)); } [Fact(Skip = "Remove to run test")] public void A_dart_lands_just_in_the_border_of_the_target() { - Assert.Equal(1, Darts.Score(10, 0)); + Assert.Equal(1, Darts.Score(0, 10)); + } + + [Fact(Skip = "Remove to run test")] + public void A_dart_lands_in_the_outer_circle() + { + Assert.Equal(1, Darts.Score(4, 4)); + } + + [Fact(Skip = "Remove to run test")] + public void A_dart_lands_right_in_the_border_between_outer_and_middle_circles() + { + Assert.Equal(5, Darts.Score(5, 0)); } [Fact(Skip = "Remove to run test")] public void A_dart_lands_in_the_middle_circle() { - Assert.Equal(5, Darts.Score(3, 3.7)); + Assert.Equal(5, Darts.Score(0.8, -0.8)); } [Fact(Skip = "Remove to run test")] - public void A_dart_lands_right_in_the_border_between_outside_and_middle_circles() + public void A_dart_lands_right_in_the_border_between_middle_and_inner_circles() { - Assert.Equal(5, Darts.Score(0, 5)); + Assert.Equal(10, Darts.Score(0, -1)); } [Fact(Skip = "Remove to run test")] public void A_dart_lands_in_the_inner_circle() { - Assert.Equal(10, Darts.Score(0, 0)); + Assert.Equal(10, Darts.Score(-0.1, -0.1)); } } \ No newline at end of file diff --git a/exercises/hamming/HammingTest.cs b/exercises/hamming/HammingTest.cs index 95cb214b13..26a05bbfa3 100644 --- a/exercises/hamming/HammingTest.cs +++ b/exercises/hamming/HammingTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 2.2.0 of the canonical data. +// This file was auto-generated based on version 2.3.0 of the canonical data. using System; using Xunit; @@ -46,4 +46,16 @@ public void Disallow_second_strand_longer() { Assert.Throws(() => Hamming.Distance("ATA", "AGTG")); } + + [Fact(Skip = "Remove to run test")] + public void Disallow_left_empty_strand() + { + Assert.Throws(() => Hamming.Distance("", "G")); + } + + [Fact(Skip = "Remove to run test")] + public void Disallow_right_empty_strand() + { + Assert.Throws(() => Hamming.Distance("G", "")); + } } \ No newline at end of file diff --git a/exercises/high-scores/Example.cs b/exercises/high-scores/Example.cs index 3506a0f3e6..44cffc1e82 100644 --- a/exercises/high-scores/Example.cs +++ b/exercises/high-scores/Example.cs @@ -14,18 +14,5 @@ public class HighScores public int PersonalBest() => _list.Max(); - public List PersonalTop() => _list.OrderByDescending(score => score).Take(3).ToList(); - - public string Report() - { - var latestScoreReport = $"Your latest score was {Latest()}."; - - var differenceOfLatestToPersonalBest = PersonalBest() - Latest(); - var latestScoreComparedToPersonalBestReport = - differenceOfLatestToPersonalBest == 0 - ? "That's your personal best!" - : $"That's {differenceOfLatestToPersonalBest} short of your personal best!"; - - return $"{latestScoreReport} {latestScoreComparedToPersonalBestReport}"; - } + public List PersonalTopThree() => _list.OrderByDescending(score => score).Take(3).ToList(); } \ No newline at end of file diff --git a/exercises/high-scores/HighScores.cs b/exercises/high-scores/HighScores.cs index 9b8339ed89..ad9e88fa9d 100644 --- a/exercises/high-scores/HighScores.cs +++ b/exercises/high-scores/HighScores.cs @@ -24,12 +24,7 @@ public int PersonalBest() throw new NotImplementedException(); } - public List PersonalTop() - { - throw new NotImplementedException(); - } - - public string Report() + public List PersonalTopThree() { throw new NotImplementedException(); } diff --git a/exercises/high-scores/HighScoresTest.cs b/exercises/high-scores/HighScoresTest.cs index fee5fe34e6..cca2e27038 100644 --- a/exercises/high-scores/HighScoresTest.cs +++ b/exercises/high-scores/HighScoresTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 2.0.0 of the canonical data. +// This file was auto-generated based on version 4.0.0 of the canonical data. using System.Collections.Generic; using Xunit; @@ -27,65 +27,37 @@ public void Personal_best() } [Fact(Skip = "Remove to run test")] - public void Personal_top() + public void Personal_top_three_from_a_list_of_scores() { - var sut = new HighScores(new List { 50, 30, 10 }); - Assert.Equal(new List { 50, 30, 10 }, sut.PersonalTop()); + var sut = new HighScores(new List { 10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70 }); + Assert.Equal(new List { 100, 90, 70 }, sut.PersonalTopThree()); } [Fact(Skip = "Remove to run test")] public void Personal_top_highest_to_lowest() { var sut = new HighScores(new List { 20, 10, 30 }); - Assert.Equal(new List { 30, 20, 10 }, sut.PersonalTop()); + Assert.Equal(new List { 30, 20, 10 }, sut.PersonalTopThree()); } [Fact(Skip = "Remove to run test")] public void Personal_top_when_there_is_a_tie() { var sut = new HighScores(new List { 40, 20, 40, 30 }); - Assert.Equal(new List { 40, 40, 30 }, sut.PersonalTop()); + Assert.Equal(new List { 40, 40, 30 }, sut.PersonalTopThree()); } [Fact(Skip = "Remove to run test")] public void Personal_top_when_there_are_less_than_3() { var sut = new HighScores(new List { 30, 70 }); - Assert.Equal(new List { 70, 30 }, sut.PersonalTop()); + Assert.Equal(new List { 70, 30 }, sut.PersonalTopThree()); } [Fact(Skip = "Remove to run test")] public void Personal_top_when_there_is_only_one() { var sut = new HighScores(new List { 40 }); - Assert.Equal(new List { 40 }, sut.PersonalTop()); - } - - [Fact(Skip = "Remove to run test")] - public void Personal_top_from_a_long_list() - { - var sut = new HighScores(new List { 10, 30, 90, 30, 100, 20, 10, 0, 30, 40, 40, 70, 70 }); - Assert.Equal(new List { 100, 90, 70 }, sut.PersonalTop()); - } - - [Fact(Skip = "Remove to run test")] - public void Message_for_new_personal_best() - { - var sut = new HighScores(new List { 20, 40, 0, 30, 70 }); - Assert.Equal("Your latest score was 70. That's your personal best!", sut.Report()); - } - - [Fact(Skip = "Remove to run test")] - public void Message_when_latest_score_is_not_the_highest_score() - { - var sut = new HighScores(new List { 20, 100, 0, 30, 70 }); - Assert.Equal("Your latest score was 70. That's 30 short of your personal best!", sut.Report()); - } - - [Fact(Skip = "Remove to run test")] - public void Message_for_repeated_personal_best() - { - var sut = new HighScores(new List { 20, 70, 50, 70, 30 }); - Assert.Equal("Your latest score was 30. That's 40 short of your personal best!", sut.Report()); + Assert.Equal(new List { 40 }, sut.PersonalTopThree()); } } \ No newline at end of file diff --git a/exercises/list-ops/ListOpsTest.cs b/exercises/list-ops/ListOpsTest.cs index 38cbc1cf28..a6c7cec265 100644 --- a/exercises/list-ops/ListOpsTest.cs +++ b/exercises/list-ops/ListOpsTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 2.3.0 of the canonical data. +// This file was auto-generated based on version 2.4.0 of the canonical data. using System; using System.Collections.Generic; @@ -171,4 +171,12 @@ public void Reverse_the_elements_of_the_list_non_empty_list() var expected = new List { 7, 5, 3, 1 }; Assert.Equal(expected, ListOps.Reverse(list)); } + + [Fact(Skip = "Remove to run test")] + public void Reverse_the_elements_of_the_list_list_of_lists_is_not_flattened() + { + var list = new List> { new List { 1, 2 }, new List { 3 }, new List(), new List { 4, 5, 6 } }; + var expected = new List> { new List { 4, 5, 6 }, new List(), new List { 3 }, new List { 1, 2 } }; + Assert.Equal(expected, ListOps.Reverse(list)); + } } \ No newline at end of file diff --git a/exercises/rational-numbers/RationalNumbersTest.cs b/exercises/rational-numbers/RationalNumbersTest.cs index 6f7ea79e63..e9f35ac4ae 100644 --- a/exercises/rational-numbers/RationalNumbersTest.cs +++ b/exercises/rational-numbers/RationalNumbersTest.cs @@ -169,7 +169,7 @@ public void Raise_a_negative_rational_number_to_the_power_of_zero() [Fact(Skip = "Remove to run test")] public void Raise_a_real_number_to_a_positive_rational_number() { - Assert.Equal(16, 8.Expreal(new RationalNumber(4, 3)), precision: 0); + Assert.Equal(16, 8.Expreal(new RationalNumber(4, 3)), precision: 7); } [Fact(Skip = "Remove to run test")] @@ -181,7 +181,7 @@ public void Raise_a_real_number_to_a_negative_rational_number() [Fact(Skip = "Remove to run test")] public void Raise_a_real_number_to_a_zero_rational_number() { - Assert.Equal(1, 2.Expreal(new RationalNumber(0, 1)), precision: 0); + Assert.Equal(1, 2.Expreal(new RationalNumber(0, 1)), precision: 7); } [Fact(Skip = "Remove to run test")] diff --git a/exercises/simple-cipher/SimpleCipherTest.cs b/exercises/simple-cipher/SimpleCipherTest.cs index e320f99c31..e42feb9ad7 100644 --- a/exercises/simple-cipher/SimpleCipherTest.cs +++ b/exercises/simple-cipher/SimpleCipherTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.2.0 of the canonical data. +// This file was auto-generated based on version 2.0.0 of the canonical data. using System; using Xunit; @@ -76,9 +76,16 @@ public void Substitution_cipher_can_wrap_on_decode() } [Fact(Skip = "Remove to run test")] - public void Substitution_cipher_can_handle_messages_longer_than_the_key() + public void Substitution_cipher_can_encode_messages_longer_than_the_key() { var sut = new SimpleCipher("abc"); Assert.Equal("iboaqcnecbfcr", sut.Encode("iamapandabear")); } + + [Fact(Skip = "Remove to run test")] + public void Substitution_cipher_can_decode_messages_longer_than_the_key() + { + var sut = new SimpleCipher("abc"); + Assert.Equal("iamapandabear", sut.Decode("iboaqcnecbfcr")); + } } \ No newline at end of file diff --git a/exercises/word-count/WordCountTest.cs b/exercises/word-count/WordCountTest.cs index 309e3049b3..fb6cba69b4 100644 --- a/exercises/word-count/WordCountTest.cs +++ b/exercises/word-count/WordCountTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.2.0 of the canonical data. +// This file was auto-generated based on version 1.3.0 of the canonical data. using System.Collections.Generic; using Xunit; @@ -152,4 +152,17 @@ public void Multiple_spaces_not_detected_as_a_word() }; Assert.Equal(expected, actual); } + + [Fact(Skip = "Remove to run test")] + public void Alternating_word_separators_not_detected_as_a_word() + { + var actual = WordCount.CountWords(",\n,one,\n ,two \n 'three'"); + var expected = new Dictionary + { + ["one"] = 1, + ["two"] = 1, + ["three"] = 1 + }; + Assert.Equal(expected, actual); + } } \ No newline at end of file diff --git a/generators/Exercises/Generators/RationalNumbers.cs b/generators/Exercises/Generators/RationalNumbers.cs index f775e8f78f..94d459d23c 100644 --- a/generators/Exercises/Generators/RationalNumbers.cs +++ b/generators/Exercises/Generators/RationalNumbers.cs @@ -28,17 +28,12 @@ private string RenderAssert(TestMethod testMethod) case "exprational": return Render.AssertEqual(RenderRationalNumber(testMethod.Expected), $"{RenderRationalNumber(testMethod.Input["r"])}.{testMethod.TestedMethod}({testMethod.Input["n"]})"); case "expreal": - return Render.AssertEqualWithin(Render.Object(testMethod.Expected), $"{testMethod.Input["x"]}.{testMethod.TestedMethod}({RenderRationalNumber(testMethod.Input["r"])})", Precision(testMethod.Expected)); + return Render.AssertEqualWithin(Render.Object(testMethod.Expected), $"{testMethod.Input["x"]}.{testMethod.TestedMethod}({RenderRationalNumber(testMethod.Input["r"])})", 7); default: throw new ArgumentOutOfRangeException(); } } private static string RenderRationalNumber(dynamic input) => $"new RationalNumber({input[0]}, {input[1]})"; - - private static int Precision(object rawValue) - => rawValue.ToString().Split(new[] { '.' }).Length <= 1 - ? 0 - : rawValue.ToString().Split(new[] { '.' })[1].Length; } } \ No newline at end of file