diff --git a/exercises/acronym/AcronymTest.cs b/exercises/acronym/AcronymTest.cs index 5f6d34d52c..970d5e4cc7 100644 --- a/exercises/acronym/AcronymTest.cs +++ b/exercises/acronym/AcronymTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.5.0 of the canonical data. +// This file was auto-generated based on version 1.7.0 of the canonical data. using Xunit; @@ -45,4 +45,16 @@ public void Consecutive_delimiters() { Assert.Equal("SIMUFTA", Acronym.Abbreviate("Something - I made up from thin air")); } + + [Fact(Skip = "Remove to run test")] + public void Apostrophes() + { + Assert.Equal("HC", Acronym.Abbreviate("Halley's Comet")); + } + + [Fact(Skip = "Remove to run test")] + public void Underscore_emphasis() + { + Assert.Equal("TRNT", Acronym.Abbreviate("The Road _Not_ Taken")); + } } \ No newline at end of file diff --git a/exercises/acronym/Example.cs b/exercises/acronym/Example.cs index 1bb25383b8..5fc6c82d0a 100644 --- a/exercises/acronym/Example.cs +++ b/exercises/acronym/Example.cs @@ -11,6 +11,6 @@ public static string Abbreviate(string phrase) private static IEnumerable Words(string phrase) { - return Regex.Matches(phrase, "[A-Z]+[a-z]*|[a-z]+").Cast().Select(m => m.Value); + return Regex.Matches(phrase, "[A-Z]+[a-z']*|[a-z']+").Cast().Select(m => m.Value); } } \ No newline at end of file diff --git a/exercises/binary-search/BinarySearchTest.cs b/exercises/binary-search/BinarySearchTest.cs index 25a85dc968..62555757c5 100644 --- a/exercises/binary-search/BinarySearchTest.cs +++ b/exercises/binary-search/BinarySearchTest.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; using Xunit; @@ -62,7 +62,7 @@ public void Identifies_that_a_value_is_not_included_in_the_array() } [Fact(Skip = "Remove to run test")] - public void A_value_smaller_than_the_arrays_smallest_value_is_not_included() + public void A_value_smaller_than_the_arrays_smallest_value_is_not_found() { var array = new[] { 1, 3, 4, 6, 8, 9, 11 }; var value = 0; @@ -70,7 +70,7 @@ public void A_value_smaller_than_the_arrays_smallest_value_is_not_included() } [Fact(Skip = "Remove to run test")] - public void A_value_larger_than_the_arrays_largest_value_is_not_included() + public void A_value_larger_than_the_arrays_largest_value_is_not_found() { var array = new[] { 1, 3, 4, 6, 8, 9, 11 }; var value = 13; @@ -78,10 +78,18 @@ public void A_value_larger_than_the_arrays_largest_value_is_not_included() } [Fact(Skip = "Remove to run test")] - public void Nothing_is_included_in_an_empty_array() + public void Nothing_is_found_in_an_empty_array() { var array = Array.Empty(); var value = 1; Assert.Equal(-1, BinarySearch.Find(array, value)); } + + [Fact(Skip = "Remove to run test")] + public void Nothing_is_found_when_the_left_and_right_bounds_cross() + { + var array = new[] { 1, 2 }; + var value = 0; + Assert.Equal(-1, BinarySearch.Find(array, value)); + } } \ No newline at end of file diff --git a/exercises/bracket-push/BracketPushTest.cs b/exercises/bracket-push/BracketPushTest.cs index 718e1cca4d..7e1cacef4b 100644 --- a/exercises/bracket-push/BracketPushTest.cs +++ b/exercises/bracket-push/BracketPushTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.4.0 of the canonical data. +// This file was auto-generated based on version 1.5.0 of the canonical data. using Xunit; @@ -102,6 +102,13 @@ public void Paired_and_incomplete_brackets() Assert.False(BracketPush.IsPaired(value)); } + [Fact(Skip = "Remove to run test")] + public void Too_many_closing_brackets() + { + var value = "[]]"; + Assert.False(BracketPush.IsPaired(value)); + } + [Fact(Skip = "Remove to run test")] public void Math_expression() { diff --git a/exercises/gigasecond/Example.cs b/exercises/gigasecond/Example.cs index 024d82c288..bef77518bf 100644 --- a/exercises/gigasecond/Example.cs +++ b/exercises/gigasecond/Example.cs @@ -2,8 +2,8 @@ public static class Gigasecond { - public static DateTime Add(DateTime birthDate) + public static DateTime Add(DateTime moment) { - return birthDate.AddSeconds(1000000000); + return moment.AddSeconds(1000000000); } } \ No newline at end of file diff --git a/exercises/gigasecond/Gigasecond.cs b/exercises/gigasecond/Gigasecond.cs index fdeecd2c7c..ead34b60fd 100644 --- a/exercises/gigasecond/Gigasecond.cs +++ b/exercises/gigasecond/Gigasecond.cs @@ -2,7 +2,7 @@ public static class Gigasecond { - public static DateTime Add(DateTime birthDate) + public static DateTime Add(DateTime moment) { throw new NotImplementedException("You need to implement this function."); } diff --git a/exercises/gigasecond/GigasecondTest.cs b/exercises/gigasecond/GigasecondTest.cs index ba2e004924..3a353e743b 100644 --- a/exercises/gigasecond/GigasecondTest.cs +++ b/exercises/gigasecond/GigasecondTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.1.0 of the canonical data. +// This file was auto-generated based on version 2.0.0 of the canonical data. using System; using Xunit; diff --git a/exercises/hamming/HammingTest.cs b/exercises/hamming/HammingTest.cs index d38c185207..95cb214b13 100644 --- a/exercises/hamming/HammingTest.cs +++ b/exercises/hamming/HammingTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 2.1.0 of the canonical data. +// This file was auto-generated based on version 2.2.0 of the canonical data. using System; using Xunit; @@ -12,73 +12,25 @@ public void Empty_strands() } [Fact(Skip = "Remove to run test")] - public void Identical_strands() + public void Single_letter_identical_strands() { Assert.Equal(0, Hamming.Distance("A", "A")); } [Fact(Skip = "Remove to run test")] - public void Long_identical_strands() - { - Assert.Equal(0, Hamming.Distance("GGACTGA", "GGACTGA")); - } - - [Fact(Skip = "Remove to run test")] - public void Complete_distance_in_single_nucleotide_strands() - { - Assert.Equal(1, Hamming.Distance("A", "G")); - } - - [Fact(Skip = "Remove to run test")] - public void Complete_distance_in_small_strands() - { - Assert.Equal(2, Hamming.Distance("AG", "CT")); - } - - [Fact(Skip = "Remove to run test")] - public void Small_distance_in_small_strands() - { - Assert.Equal(1, Hamming.Distance("AT", "CT")); - } - - [Fact(Skip = "Remove to run test")] - public void Small_distance() + public void Single_letter_different_strands() { - Assert.Equal(1, Hamming.Distance("GGACG", "GGTCG")); + Assert.Equal(1, Hamming.Distance("G", "T")); } [Fact(Skip = "Remove to run test")] - public void Small_distance_in_long_strands() - { - Assert.Equal(2, Hamming.Distance("ACCAGGG", "ACTATGG")); - } - - [Fact(Skip = "Remove to run test")] - public void Non_unique_character_in_first_strand() - { - Assert.Equal(1, Hamming.Distance("AAG", "AAA")); - } - - [Fact(Skip = "Remove to run test")] - public void Non_unique_character_in_second_strand() - { - Assert.Equal(1, Hamming.Distance("AAA", "AAG")); - } - - [Fact(Skip = "Remove to run test")] - public void Same_nucleotides_in_different_positions() - { - Assert.Equal(2, Hamming.Distance("TAG", "GAT")); - } - - [Fact(Skip = "Remove to run test")] - public void Large_distance() + public void Long_identical_strands() { - Assert.Equal(4, Hamming.Distance("GATACA", "GCATAA")); + Assert.Equal(0, Hamming.Distance("GGACTGAAATCTG", "GGACTGAAATCTG")); } [Fact(Skip = "Remove to run test")] - public void Large_distance_in_off_by_one_strand() + public void Long_different_strands() { Assert.Equal(9, Hamming.Distance("GGACGGATTCTG", "AGGACGGATTCT")); } diff --git a/exercises/isogram/IsogramTest.cs b/exercises/isogram/IsogramTest.cs index 957e948bc8..e1b5fb5a9d 100644 --- a/exercises/isogram/IsogramTest.cs +++ b/exercises/isogram/IsogramTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.6.0 of the canonical data. +// This file was auto-generated based on version 1.7.0 of the canonical data. using Xunit; @@ -52,6 +52,12 @@ public void Hypothetical_isogrammic_word_with_hyphen() Assert.True(Isogram.IsIsogram("thumbscrew-japingly")); } + [Fact(Skip = "Remove to run test")] + public void Hypothetical_word_with_duplicated_character_following_hyphen() + { + Assert.False(Isogram.IsIsogram("thumbscrew-jappingly")); + } + [Fact(Skip = "Remove to run test")] public void Isogram_with_duplicated_hyphen() { diff --git a/exercises/luhn/LuhnTest.cs b/exercises/luhn/LuhnTest.cs index 49035f01b7..f7ea5080a4 100644 --- a/exercises/luhn/LuhnTest.cs +++ b/exercises/luhn/LuhnTest.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.4.0 of the canonical data. using Xunit; @@ -46,12 +46,24 @@ public void Invalid_credit_card() Assert.False(Luhn.IsValid("8273 1232 7352 0569")); } + [Fact(Skip = "Remove to run test")] + public void Valid_number_with_an_even_number_of_digits() + { + Assert.True(Luhn.IsValid("095 245 88")); + } + [Fact(Skip = "Remove to run test")] public void Valid_strings_with_a_non_digit_included_become_invalid() { Assert.False(Luhn.IsValid("055a 444 285")); } + [Fact(Skip = "Remove to run test")] + public void Valid_strings_with_a_non_digit_added_at_the_end_become_invalid() + { + Assert.False(Luhn.IsValid("059a")); + } + [Fact(Skip = "Remove to run test")] public void Valid_strings_with_punctuation_included_become_invalid() { diff --git a/exercises/matrix/Example.cs b/exercises/matrix/Example.cs index 8c926dda48..9b0b63e193 100644 --- a/exercises/matrix/Example.cs +++ b/exercises/matrix/Example.cs @@ -14,8 +14,8 @@ public Matrix(string input) public int Rows => _rows.Length; public int Cols => _cols.Length; - public int[] Row(int row) => _rows[row]; - public int[] Column(int col) => _cols[col]; + public int[] Row(int row) => _rows[row - 1]; + public int[] Column(int col) => _cols[col - 1]; private static int[][] ParseRows(string input) { diff --git a/exercises/matrix/MatrixTest.cs b/exercises/matrix/MatrixTest.cs index 034441e333..98bf7c3a59 100644 --- a/exercises/matrix/MatrixTest.cs +++ b/exercises/matrix/MatrixTest.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; @@ -8,55 +8,55 @@ public class MatrixTest public void Extract_row_from_one_number_matrix() { var sut = new Matrix("1"); - Assert.Equal(new[] { 1 }, sut.Row(0)); + Assert.Equal(new[] { 1 }, sut.Row(1)); } [Fact(Skip = "Remove to run test")] public void Can_extract_row() { var sut = new Matrix("1 2\n3 4"); - Assert.Equal(new[] { 3, 4 }, sut.Row(1)); + Assert.Equal(new[] { 3, 4 }, sut.Row(2)); } [Fact(Skip = "Remove to run test")] public void Extract_row_where_numbers_have_different_widths() { var sut = new Matrix("1 2\n10 20"); - Assert.Equal(new[] { 10, 20 }, sut.Row(1)); + Assert.Equal(new[] { 10, 20 }, sut.Row(2)); } [Fact(Skip = "Remove to run test")] public void Can_extract_row_from_non_square_matrix() { var sut = new Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6"); - Assert.Equal(new[] { 7, 8, 9 }, sut.Row(2)); + Assert.Equal(new[] { 7, 8, 9 }, sut.Row(3)); } [Fact(Skip = "Remove to run test")] public void Extract_column_from_one_number_matrix() { var sut = new Matrix("1"); - Assert.Equal(new[] { 1 }, sut.Column(0)); + Assert.Equal(new[] { 1 }, sut.Column(1)); } [Fact(Skip = "Remove to run test")] public void Can_extract_column() { var sut = new Matrix("1 2 3\n4 5 6\n7 8 9"); - Assert.Equal(new[] { 3, 6, 9 }, sut.Column(2)); + Assert.Equal(new[] { 3, 6, 9 }, sut.Column(3)); } [Fact(Skip = "Remove to run test")] public void Can_extract_column_from_non_square_matrix() { var sut = new Matrix("1 2 3\n4 5 6\n7 8 9\n8 7 6"); - Assert.Equal(new[] { 3, 6, 9, 6 }, sut.Column(2)); + Assert.Equal(new[] { 3, 6, 9, 6 }, sut.Column(3)); } [Fact(Skip = "Remove to run test")] public void Extract_column_where_numbers_have_different_widths() { var sut = new Matrix("89 1903 3\n18 3 1\n9 4 800"); - Assert.Equal(new[] { 1903, 3, 4 }, sut.Column(1)); + Assert.Equal(new[] { 1903, 3, 4 }, sut.Column(2)); } } \ No newline at end of file diff --git a/exercises/matrix/README.md b/exercises/matrix/README.md index a94a3512d7..ffd7bc2bbd 100644 --- a/exercises/matrix/README.md +++ b/exercises/matrix/README.md @@ -14,11 +14,11 @@ So given a string with embedded newlines like: representing this matrix: ```text - 0 1 2 + 1 2 3 |--------- -0 | 9 8 7 -1 | 5 3 2 -2 | 6 6 7 +1 | 9 8 7 +2 | 5 3 2 +3 | 6 6 7 ``` your code should be able to spit out: diff --git a/exercises/phone-number/PhoneNumberTest.cs b/exercises/phone-number/PhoneNumberTest.cs index 5e500d9418..79c7276a5c 100644 --- a/exercises/phone-number/PhoneNumberTest.cs +++ b/exercises/phone-number/PhoneNumberTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.6.1 of the canonical data. +// This file was auto-generated based on version 1.7.0 of the canonical data. using System; using Xunit; diff --git a/exercises/rest-api/RestApiTest.cs b/exercises/rest-api/RestApiTest.cs index b14b877641..e32d0950b5 100644 --- a/exercises/rest-api/RestApiTest.cs +++ b/exercises/rest-api/RestApiTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.0.2 of the canonical data. +// This file was auto-generated based on version 1.1.1 of the canonical data. using Xunit; @@ -98,4 +98,16 @@ public void Lender_owes_borrower_less_than_new_loan() var expected = "[{\"name\":\"Adam\",\"owes\":{},\"owed_by\":{\"Bob\":1.0},\"balance\":1.0},{\"name\":\"Bob\",\"owes\":{\"Adam\":1.0},\"owed_by\":{},\"balance\":-1.0}]"; Assert.Equal(expected, actual); } + + [Fact(Skip = "Remove to run test")] + public void Lender_owes_borrower_same_as_new_loan() + { + var url = "/iou"; + var payload = "{\"lender\":\"Adam\",\"borrower\":\"Bob\",\"amount\":3.0}"; + var database = "[{\"name\":\"Adam\",\"owes\":{\"Bob\":3.0},\"owed_by\":{},\"balance\":-3.0},{\"name\":\"Bob\",\"owes\":{},\"owed_by\":{\"Adam\":3.0},\"balance\":3.0}]"; + var sut = new RestApi(database); + var actual = sut.Post(url, payload); + var expected = "[{\"name\":\"Adam\",\"owes\":{},\"owed_by\":{},\"balance\":0.0},{\"name\":\"Bob\",\"owes\":{},\"owed_by\":{},\"balance\":0.0}]"; + Assert.Equal(expected, actual); + } } \ No newline at end of file diff --git a/exercises/saddle-points/Example.cs b/exercises/saddle-points/Example.cs index 24532176a4..78a71d89c0 100644 --- a/exercises/saddle-points/Example.cs +++ b/exercises/saddle-points/Example.cs @@ -10,7 +10,9 @@ public class SaddlePoints var columnCount = matrix.GetLength(1); var maxRows = Rows(matrix, rowCount, columnCount).Select(r => r.Max()).ToArray(); var minCols = Columns(matrix, columnCount, rowCount).Select(r => r.Min()).ToArray(); - return Coordinates(rowCount, columnCount).Where(x => IsSaddlePoint(x, maxRows, minCols, matrix)) + return Coordinates(rowCount, columnCount) + .Where(x => IsSaddlePoint(x, maxRows, minCols, matrix)) + .Select(pair => (pair.Item1 + 1, pair.Item2 + 1)) .ToArray(); } diff --git a/exercises/saddle-points/README.md b/exercises/saddle-points/README.md index 9c3bdc6714..705c812acc 100644 --- a/exercises/saddle-points/README.md +++ b/exercises/saddle-points/README.md @@ -5,14 +5,14 @@ Detect saddle points in a matrix. So say you have a matrix like so: ```text - 0 1 2 + 1 2 3 |--------- -0 | 9 8 7 -1 | 5 3 2 <--- saddle point at (1,0) -2 | 6 6 7 +1 | 9 8 7 +2 | 5 3 2 <--- addle point at column 1, row 2, with value 5 +3 | 6 6 7 ``` -It has a saddle point at (1, 0). +It has a saddle point at column 1, row 2. It's called a "saddle point" because it is greater than or equal to every element in its row and less than or equal to every element in diff --git a/exercises/saddle-points/SaddlePointsTest.cs b/exercises/saddle-points/SaddlePointsTest.cs index fdf6d0e683..76a1669939 100644 --- a/exercises/saddle-points/SaddlePointsTest.cs +++ b/exercises/saddle-points/SaddlePointsTest.cs @@ -1,4 +1,4 @@ -// This file was auto-generated based on version 1.3.0 of the canonical data. +// This file was auto-generated based on version 1.5.0 of the canonical data. using System; using Xunit; @@ -15,7 +15,7 @@ public void Can_identify_single_saddle_point() { 6, 6, 7 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (1, 0) }; + var expected = new[] { (2, 1) }; Assert.Equal(expected, actual); } @@ -50,7 +50,7 @@ public void Can_identify_multiple_saddle_points_in_a_column() { 1, 5, 4 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (0, 1), (1, 1), (2, 1) }; + var expected = new[] { (1, 2), (2, 2), (3, 2) }; Assert.Equal(expected, actual); } @@ -64,7 +64,7 @@ public void Can_identify_multiple_saddle_points_in_a_row() { 7, 5, 6 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (1, 0), (1, 1), (1, 2) }; + var expected = new[] { (2, 1), (2, 2), (2, 3) }; Assert.Equal(expected, actual); } @@ -78,7 +78,7 @@ public void Can_identify_saddle_point_in_bottom_right_corner() { 3, 2, 5 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (2, 2) }; + var expected = new[] { (3, 3) }; Assert.Equal(expected, actual); } @@ -91,7 +91,7 @@ public void Can_identify_saddle_points_in_a_non_square_matrix() { 3, 2, 4 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (0, 0), (0, 2) }; + var expected = new[] { (1, 1), (1, 3) }; Assert.Equal(expected, actual); } @@ -106,7 +106,7 @@ public void Can_identify_that_saddle_points_in_a_single_column_matrix_are_those_ { 1 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (1, 0), (3, 0) }; + var expected = new[] { (2, 1), (4, 1) }; Assert.Equal(expected, actual); } @@ -118,7 +118,7 @@ public void Can_identify_that_saddle_points_in_a_single_row_matrix_are_those_wit { 2, 5, 3, 5 } }; var actual = SaddlePoints.Calculate(matrix); - var expected = new[] { (0, 1), (0, 3) }; + var expected = new[] { (1, 2), (1, 4) }; Assert.Equal(expected, actual); } } \ No newline at end of file diff --git a/generators/Exercises/Generators/Gigasecond.cs b/generators/Exercises/Generators/Gigasecond.cs index 89b931197b..8b07e44d4a 100644 --- a/generators/Exercises/Generators/Gigasecond.cs +++ b/generators/Exercises/Generators/Gigasecond.cs @@ -9,7 +9,7 @@ public class Gigasecond : GeneratorExercise { protected override void UpdateTestMethod(TestMethod testMethod) { - testMethod.Input["birthdate"] = DateTime.Parse(testMethod.Input["birthdate"].ToString()); + testMethod.Input["moment"] = DateTime.Parse(testMethod.Input["moment"].ToString()); } protected override void UpdateNamespaces(ISet namespaces)