diff --git a/.gitignore b/.gitignore index 5e2dfe72fb..2edac62927 100644 --- a/.gitignore +++ b/.gitignore @@ -11,4 +11,6 @@ build/ packages/ paket-files TestResult.xml -junit-results.xml \ No newline at end of file +junit-results.xml +exercises/obj/ +exercises/bin/ \ No newline at end of file diff --git a/build.fsx b/build.fsx index 3cfffc6e29..ff8ac8f94d 100644 --- a/build.fsx +++ b/build.fsx @@ -2,7 +2,7 @@ #r "./packages/FAKE/tools/FakeLib.dll" open Fake -open Fake.Testing.NUnit3 +open Fake.Testing.XUnit2 // Directories let buildDir = "./build/" @@ -11,7 +11,6 @@ let sourceDir = "./exercises/" // Files let solutionFile = buildDir @@ "/exercises.csproj" let compiledOutput = buildDir @@ "xcsharp.dll" -let nunitToJunitTransformFile = "./paket-files" @@ "nunit" @@ "nunit-transforms" @@ "nunit3-junit" @@ "nunit3-junit.xslt" // Targets Target "PrepareUnchanged" (fun _ -> @@ -28,7 +27,7 @@ Target "PrepareTests" (fun _ -> CleanDirs [buildDir] CopyDir buildDir sourceDir allFiles - let ignorePattern = "(\[Ignore\(\"Remove to run test\"\)]|, Ignore = \"Remove to run test case\")" + let ignorePattern = "Skip\s*=\s*\"Remove to run test\"" !! (buildDir @@ "**/*Test.cs") |> RegexReplaceInFilesWithEncoding ignorePattern "" System.Text.Encoding.UTF8 @@ -40,19 +39,8 @@ Target "BuildTests" (fun _ -> ) Target "Test" (fun _ -> - if getEnvironmentVarAsBool "APPVEYOR" then - [compiledOutput] - |> NUnit3 (fun p -> { p with - ShadowCopy = false - ToolPath = "nunit3-console.exe" }) - else if getEnvironmentVarAsBool "CIRCLECI" then - [compiledOutput] - |> NUnit3 (fun p -> { p with - ShadowCopy = false - ResultSpecs = [sprintf "junit-results.xml;transform=%s" nunitToJunitTransformFile] }) - else - [compiledOutput] - |> NUnit3 (fun p -> { p with ShadowCopy = false }) + [compiledOutput] + |> xUnit2 (fun p -> { p with ShadowCopy = false }) ) // Build order diff --git a/circle.yml b/circle.yml index a83b9814cb..44d5882948 100644 --- a/circle.yml +++ b/circle.yml @@ -9,8 +9,4 @@ dependencies: - sudo apt-get install mono-complete test: override: - - ./build.sh - post: - - mkdir -p $CIRCLE_TEST_REPORTS/junit/ - - sed -i '1 s/^\xef\xbb\xbf//' .*/junit-results.xml - - find . -type f -regex ".*/junit-results.xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; \ No newline at end of file + - ./build.sh \ No newline at end of file diff --git a/exercises/accumulate/AccumulateTest.cs b/exercises/accumulate/AccumulateTest.cs index c424a87af5..f51ec956b2 100644 --- a/exercises/accumulate/AccumulateTest.cs +++ b/exercises/accumulate/AccumulateTest.cs @@ -1,38 +1,32 @@ using System; using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; -[TestFixture] public class AccumulateTest { - [Test] + [Fact] public void Empty_accumulation_produces_empty_accumulation() { - Assert.That(new int[0].Accumulate(x => x * x), Is.EqualTo(new int[0])); + Assert.Equal(new int[0], new int[0].Accumulate(x => x * x)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Accumulate_squares() { - Assert.That(new[] { 1, 2, 3 }.Accumulate(x => x * x), Is.EqualTo(new[] { 1, 4, 9 })); + Assert.Equal(new[] { 1, 4, 9 }, new[] { 1, 2, 3 }.Accumulate(x => x * x)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Accumulate_upcases() { - Assert.That(new List { "hello", "world" }.Accumulate(x => x.ToUpper()), - Is.EqualTo(new List { "HELLO", "WORLD" })); + Assert.Equal(new List { "HELLO", "WORLD" }, new List { "hello", "world" }.Accumulate(x => x.ToUpper())); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Accumulate_reversed_strings() { - Assert.That("the quick brown fox etc".Split(' ').Accumulate(Reverse), - Is.EqualTo("eht kciuq nworb xof cte".Split(' '))); + Assert.Equal("eht kciuq nworb xof cte".Split(' '), "the quick brown fox etc".Split(' ').Accumulate(Reverse)); } private static string Reverse(string value) @@ -42,33 +36,28 @@ private static string Reverse(string value) return new string(array); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Accumulate_within_accumulate() { var actual = new[] { "a", "b", "c" }.Accumulate(c => string.Join(" ", new[] { "1", "2", "3" }.Accumulate(d => c + d))); - Assert.That(actual, Is.EqualTo(new[] { "a1 a2 a3", "b1 b2 b3", "c1 c2 c3" })); + Assert.Equal(new[] { "a1 a2 a3", "b1 b2 b3", "c1 c2 c3" }, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Accumulate_is_lazy() { var counter = 0; var accumulation = new[] { 1, 2, 3 }.Accumulate(x => x * counter++); - Assert.That(counter, Is.EqualTo(0)); + Assert.Equal(0, counter); accumulation.ToList(); - Assert.That(counter, Is.EqualTo(3)); + Assert.Equal(3, counter); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Accumulate_allows_different_return_type() { - Assert.That( - new[] { 1, 2, 3 }.Accumulate(x => x.ToString()), - Is.EqualTo(new[] { "1", "2", "3" })); + Assert.Equal(new[] { "1", "2", "3" }, new[] { 1, 2, 3 }.Accumulate(x => x.ToString())); } } \ No newline at end of file diff --git a/exercises/acronym/AcronymTest.cs b/exercises/acronym/AcronymTest.cs index 2aa04a84e5..3ebb91534f 100644 --- a/exercises/acronym/AcronymTest.cs +++ b/exercises/acronym/AcronymTest.cs @@ -1,25 +1,22 @@ -namespace Exercism -{ - using NUnit.Framework; +using Xunit; - [TestFixture] - public class AcronymTest +public class AcronymTest +{ + [Fact] + public void Empty_string_abbreviated_to_empty_string() { - [Test] - public void Empty_string_abbreviated_to_empty_string() - { - Assert.That(Acronym.Abbreviate(string.Empty), Is.EqualTo(string.Empty)); - } + Assert.Equal(string.Empty, Acronym.Abbreviate(string.Empty)); + } - [TestCase("Portable Network Graphics", ExpectedResult = "PNG", Ignore = "Remove to run test case")] - [TestCase("Ruby on Rails", ExpectedResult = "ROR", Ignore = "Remove to run test case")] - [TestCase("HyperText Markup Language", ExpectedResult = "HTML", Ignore = "Remove to run test case")] - [TestCase("First In, First Out", ExpectedResult = "FIFO", Ignore = "Remove to run test case")] - [TestCase("PHP: Hypertext Preprocessor", ExpectedResult = "PHP", Ignore = "Remove to run test case")] - [TestCase("Complementary metal-oxide semiconductor", ExpectedResult = "CMOS", Ignore = "Remove to run test case")] - public string Phrase_abbreviated_to_acronym(string phrase) - { - return Acronym.Abbreviate(phrase); - } + [Theory(Skip = "Remove to run test")] + [InlineData("Portable Network Graphics", "PNG")] + [InlineData("Ruby on Rails", "ROR")] + [InlineData("HyperText Markup Language", "HTML")] + [InlineData("First In, First Out", "FIFO")] + [InlineData("PHP: Hypertext Preprocessor", "PHP")] + [InlineData("Complementary metal-oxide semiconductor", "CMOS")] + public void Phrase_abbreviated_to_acronym(string phrase, string expected) + { + Assert.Equal(expected, Acronym.Abbreviate(phrase)); } } \ No newline at end of file diff --git a/exercises/acronym/Example.cs b/exercises/acronym/Example.cs index 1fe9b634cb..1bb25383b8 100644 --- a/exercises/acronym/Example.cs +++ b/exercises/acronym/Example.cs @@ -1,19 +1,16 @@ -namespace Exercism -{ - using System.Collections.Generic; - using System.Linq; - using System.Text.RegularExpressions; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; - public static class Acronym +public static class Acronym +{ + public static string Abbreviate(string phrase) { - public static string Abbreviate(string phrase) - { - return Words(phrase).Aggregate("", (abbr, word) => abbr + char.ToUpperInvariant(word[0])); - } + return Words(phrase).Aggregate("", (abbr, word) => abbr + char.ToUpperInvariant(word[0])); + } - private static IEnumerable Words(string phrase) - { - return Regex.Matches(phrase, "[A-Z]+[a-z]*|[a-z]+").Cast().Select(m => m.Value); - } + private static IEnumerable Words(string phrase) + { + 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/all-your-base/AllYourBaseTest.cs b/exercises/all-your-base/AllYourBaseTest.cs index 21899bc84c..4347393e19 100644 --- a/exercises/all-your-base/AllYourBaseTest.cs +++ b/exercises/all-your-base/AllYourBaseTest.cs @@ -1,98 +1,89 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class AllYourBaseTest { - [Test] + [Fact] public void Single_bit_one_to_decimal() { const int inputBase = 2; var inputDigits = new [] { 1 }; const int outputBase = 10; var outputDigits = new [] { 1 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Binary_to_single_decimal() { const int inputBase = 2; var inputDigits = new [] { 1, 0, 1 }; const int outputBase = 10; var outputDigits = new [] { 5 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Single_decimal_to_binary() { const int inputBase = 10; var inputDigits = new [] { 5 }; const int outputBase = 2; var outputDigits = new [] { 1, 0, 1 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Binary_to_multiple_decimal() { const int inputBase = 2; var inputDigits = new [] { 1, 0, 1, 0, 1, 0 }; const int outputBase = 10; var outputDigits = new [] { 4, 2 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decimal_to_binary() { const int inputBase = 10; var inputDigits = new [] { 4, 2 }; const int outputBase = 2; var outputDigits = new [] { 1, 0, 1, 0, 1, 0 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Trinary_to_hexadecimal() { const int inputBase = 3; var inputDigits = new [] { 1, 1, 2, 0 }; const int outputBase = 16; var outputDigits = new [] { 2, 10 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Hexadecimal_to_trinary() { const int inputBase = 16; var inputDigits = new [] { 2, 10 }; const int outputBase = 3; var outputDigits = new [] { 1, 1, 2, 0 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Using_15_bit_integer() { const int inputBase = 97; var inputDigits = new [] { 3, 46, 60 }; const int outputBase = 73; var outputDigits = new [] { 6, 10, 45 }; - Assert.That(Base.Rebase(inputBase, inputDigits, outputBase), Is.EqualTo(outputDigits)); + Assert.Equal(outputDigits, Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_array() { const int inputBase = 2; @@ -101,8 +92,7 @@ public void Empty_array() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Single_zero() { const int inputBase = 10; @@ -111,8 +101,7 @@ public void Single_zero() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_zeros() { const int inputBase = 10; @@ -121,8 +110,7 @@ public void Multiple_zeros() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Leading_zeros() { const int inputBase = 7; @@ -131,8 +119,7 @@ public void Leading_zeros() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Negative_digit() { const int inputBase = 2; @@ -141,8 +128,7 @@ public void Negative_digit() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Invalid_positive_digit() { const int inputBase = 2; @@ -151,8 +137,7 @@ public void Invalid_positive_digit() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void First_base_is_one() { const int inputBase = 1; @@ -161,8 +146,7 @@ public void First_base_is_one() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Second_base_is_one() { const int inputBase = 2; @@ -171,8 +155,7 @@ public void Second_base_is_one() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void First_base_is_zero() { const int inputBase = 0; @@ -181,8 +164,7 @@ public void First_base_is_zero() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Second_base_is_zero() { const int inputBase = 10; @@ -191,8 +173,7 @@ public void Second_base_is_zero() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void First_base_is_negative() { const int inputBase = -2; @@ -201,8 +182,7 @@ public void First_base_is_negative() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Second_base_is_negative() { const int inputBase = 2; @@ -211,8 +191,7 @@ public void Second_base_is_negative() Assert.Throws(() => Base.Rebase(inputBase, inputDigits, outputBase)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Both_bases_are_negative() { const int inputBase = -2; diff --git a/exercises/allergies/AllergiesTest.cs b/exercises/allergies/AllergiesTest.cs index 98c3284e36..7f1cde649d 100644 --- a/exercises/allergies/AllergiesTest.cs +++ b/exercises/allergies/AllergiesTest.cs @@ -1,84 +1,73 @@ using System.Collections.Generic; -using NUnit.Framework; +using Xunit; -[TestFixture] public class AllergiesTest { - [Test] + [Fact] public void No_allergies_means_not_allergic() { var allergies = new Allergies(0); - Assert.That(allergies.AllergicTo("peanuts"), Is.False); - Assert.That(allergies.AllergicTo("cats"), Is.False); - Assert.That(allergies.AllergicTo("strawberries"), Is.False); + Assert.False(allergies.AllergicTo("peanuts")); + Assert.False(allergies.AllergicTo("cats")); + Assert.False(allergies.AllergicTo("strawberries")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_eggs() { var allergies = new Allergies(1); - Assert.That(allergies.AllergicTo("eggs"), Is.True); + Assert.True(allergies.AllergicTo("eggs")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_eggs_in_addition_to_other_stuff() { var allergies = new Allergies(5); - Assert.That(allergies.AllergicTo("eggs"), Is.True); - Assert.That(allergies.AllergicTo("shellfish"), Is.True); - Assert.That(allergies.AllergicTo("strawberries"), Is.False); + Assert.True(allergies.AllergicTo("eggs")); + Assert.True(allergies.AllergicTo("shellfish")); + Assert.False(allergies.AllergicTo("strawberries")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void No_allergies_at_all() { var allergies = new Allergies(0); - Assert.That(allergies.List(), Is.Empty); + Assert.Empty(allergies.List()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_just_eggs() { var allergies = new Allergies(1); - Assert.That(allergies.List(), Is.EqualTo(new List { "eggs" })); + Assert.Equal(new List { "eggs" }, allergies.List()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_just_peanuts() { var allergies = new Allergies(2); - Assert.That(allergies.List(), Is.EqualTo(new List { "peanuts" })); + Assert.Equal(new List { "peanuts" }, allergies.List()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_eggs_and_peanuts() { var allergies = new Allergies(3); - Assert.That(allergies.List(), Is.EqualTo(new List { "eggs", "peanuts" })); + Assert.Equal(new List { "eggs", "peanuts" }, allergies.List()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_lots_of_stuff() { var allergies = new Allergies(248); - Assert.That(allergies.List(), - Is.EqualTo(new List { "strawberries", "tomatoes", "chocolate", "pollen", "cats" })); + Assert.Equal(new List { "strawberries", "tomatoes", "chocolate", "pollen", "cats" }, allergies.List()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allergic_to_everything() { var allergies = new Allergies(255); - Assert.That(allergies.List(), - Is.EqualTo(new List + Assert.Equal(new List { "eggs", "peanuts", @@ -88,16 +77,15 @@ public void Allergic_to_everything() "chocolate", "pollen", "cats" - })); + }, + allergies.List()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Ignore_non_allergen_score_parts() { var allergies = new Allergies(509); - Assert.That(allergies.List(), - Is.EqualTo(new List + Assert.Equal(new List { "eggs", "shellfish", @@ -106,6 +94,6 @@ public void Ignore_non_allergen_score_parts() "chocolate", "pollen", "cats" - })); + }, allergies.List()); } } \ No newline at end of file diff --git a/exercises/alphametics/AlphameticsTest.cs b/exercises/alphametics/AlphameticsTest.cs index 20c6b840e1..1648a3e1b8 100644 --- a/exercises/alphametics/AlphameticsTest.cs +++ b/exercises/alphametics/AlphameticsTest.cs @@ -1,9 +1,10 @@ -using NUnit.Framework; +using Xunit; using System.Collections.Generic; +using System; public class AlphameticsTest { - [Test] + [Fact] public void Puzzle_with_three_letters() { var actual = Alphametics.Solve("I + BB == ILL"); @@ -13,25 +14,22 @@ public void Puzzle_with_three_letters() ['B'] = 9, ['L'] = 0 }; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Solution_must_have_unique_value_for_each_letter() { - Assert.That(() => Alphametics.Solve("A == B"), Throws.Exception); + Assert.Throws(() => Alphametics.Solve("A == B")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Leading_zero_solution_is_invalid() { - Assert.That(() => Alphametics.Solve("ACA + DD == BD"), Throws.Exception); + Assert.Throws(() => Alphametics.Solve("ACA + DD == BD")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Puzzle_with_four_letters() { var actual = Alphametics.Solve("AS + A == MOM"); @@ -42,11 +40,10 @@ public void Puzzle_with_four_letters() ['M'] = 1, ['O'] = 0 }; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Puzzle_with_six_letters() { var actual = Alphametics.Solve("NO + NO + TOO == LATE"); @@ -59,11 +56,10 @@ public void Puzzle_with_six_letters() ['A'] = 0, ['E'] = 2 }; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Puzzle_with_seven_letters() { var actual = Alphametics.Solve("HE + SEES + THE == LIGHT"); @@ -77,11 +73,10 @@ public void Puzzle_with_seven_letters() ['S'] = 9, ['T'] = 7, }; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Puzzle_with_eight_letters() { var actual = Alphametics.Solve("SEND + MORE == MONEY"); @@ -96,11 +91,10 @@ public void Puzzle_with_eight_letters() ['R'] = 8, ['Y'] = 2, }; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Puzzle_with_ten_letters() { var actual = Alphametics.Solve("AND + A + STRONG + OFFENSE + AS + A + GOOD == DEFENSE"); @@ -117,6 +111,6 @@ public void Puzzle_with_ten_letters() ['S'] = 6, ['T'] = 9, }; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } } diff --git a/exercises/alphametics/Example.cs b/exercises/alphametics/Example.cs index 0630272fa6..c3fe804e87 100644 --- a/exercises/alphametics/Example.cs +++ b/exercises/alphametics/Example.cs @@ -10,7 +10,12 @@ public static IDictionary Solve(string equation) var expression = ExpressionParser.Equation.Parse(equation); var maps = GetValidMaps(expression.Chars, expression.StartChars); - return maps.First(map => expression.Solve(map) == 0); + var solution = maps.FirstOrDefault(map => expression.Solve(map) == 0); + + if (solution == null) + throw new ArgumentException(nameof(equation)); + + return solution; } private static IEnumerable> GetValidMaps(HashSet chars, HashSet startChars) diff --git a/exercises/anagram/AnagramTest.cs b/exercises/anagram/AnagramTest.cs index b34dce32f7..c2e4ccb07a 100644 --- a/exercises/anagram/AnagramTest.cs +++ b/exercises/anagram/AnagramTest.cs @@ -1,95 +1,86 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class AnagramTest { - [Test] + [Fact] public void No_matches() { var detector = new Anagram("diaper"); var words = new[] { "hello", "world", "zombies", "pants" }; var results = new string[0]; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Detect_simple_anagram() { var detector = new Anagram("ant"); var words = new[] { "tan", "stand", "at" }; var results = new[] { "tan" }; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Detect_multiple_anagrams() { var detector = new Anagram("master"); var words = new[] { "stream", "pigeon", "maters" }; var results = new[] { "maters", "stream" }; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Does_not_confuse_different_duplicates() { var detector = new Anagram("galea"); var words = new[] { "eagle" }; var results = new string[0]; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Identical_word_is_not_anagram() { var detector = new Anagram("corn"); var words = new[] { "corn", "dark", "Corn", "rank", "CORN", "cron", "park" }; var results = new[] { "cron" }; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Eliminate_anagrams_with_same_checksum() { var detector = new Anagram("mass"); var words = new[] { "last" }; var results = new string[0]; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Eliminate_anagram_subsets() { var detector = new Anagram("good"); var words = new[] { "dog", "goody" }; var results = new string[0]; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Detect_anagrams() { var detector = new Anagram("allergy"); var words = new[] { "gallery", "ballerina", "regally", "clergy", "largely", "leading" }; var results = new[] { "gallery", "largely", "regally" }; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Anagrams_are_case_insensitive() { var detector = new Anagram("Orchestra"); var words = new[] { "cashregister", "Carthorse", "radishes" }; var results = new[] { "Carthorse" }; - Assert.That(detector.Match(words), Is.EquivalentTo(results)); + Assert.Equal(results, detector.Match(words)); } } \ No newline at end of file diff --git a/exercises/atbash-cipher/AtbashTest.cs b/exercises/atbash-cipher/AtbashTest.cs index 5f197fe2c5..9f663c4e02 100644 --- a/exercises/atbash-cipher/AtbashTest.cs +++ b/exercises/atbash-cipher/AtbashTest.cs @@ -1,17 +1,17 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class AtbashTest { - [TestCase("no", ExpectedResult = "ml")] - [TestCase("yes", ExpectedResult = "bvh", Ignore = "Remove to run test case")] - [TestCase("OMG", ExpectedResult = "lnt", Ignore = "Remove to run test case")] - [TestCase("mindblowingly", ExpectedResult = "nrmwy oldrm tob", Ignore = "Remove to run test case")] - [TestCase("Testing, 1 2 3, testing.", ExpectedResult = "gvhgr mt123 gvhgr mt", Ignore = "Remove to run test case")] - [TestCase("Truth is fiction.", ExpectedResult = "gifgs rhurx grlm", Ignore = "Remove to run test case")] - [TestCase("The quick brown fox jumps over the lazy dog.", ExpectedResult = "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt", Ignore = "Remove to run test case")] - public string Encodes_words_using_atbash_cipher(string words) + [Theory] + [InlineData("no", "ml")] + [InlineData("yes", "bvh")] + [InlineData("OMG", "lnt")] + [InlineData("mindblowingly", "nrmwy oldrm tob")] + [InlineData("Testing, 1 2 3, testing.", "gvhgr mt123 gvhgr mt")] + [InlineData("Truth is fiction.", "gifgs rhurx grlm")] + [InlineData("The quick brown fox jumps over the lazy dog.", "gsvjf rxpyi ldmul cqfnk hlevi gsvoz abwlt")] + public void Encodes_words_using_atbash_cipher(string words, string expected) { - return Atbash.Encode(words); + Assert.Equal(expected, Atbash.Encode(words)); } } \ No newline at end of file diff --git a/exercises/bank-account/BankAccountTest.cs b/exercises/bank-account/BankAccountTest.cs index b82a44003b..d001d043b8 100644 --- a/exercises/bank-account/BankAccountTest.cs +++ b/exercises/bank-account/BankAccountTest.cs @@ -1,21 +1,20 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using NUnit.Framework; +using Xunit; public class BankAccountTest { - [Test] + [Fact] public void Returns_empty_balance_after_opening() { var account = new BankAccount(); account.Open(); - Assert.That(account.Balance, Is.EqualTo(0)); + Assert.Equal(0, account.Balance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Check_basic_balance() { var account = new BankAccount(); @@ -26,12 +25,11 @@ public void Check_basic_balance() account.UpdateBalance(10); var updatedBalance = account.Balance; - Assert.That(openingBalance, Is.EqualTo(0)); - Assert.That(updatedBalance, Is.EqualTo(10)); + Assert.Equal(0, openingBalance); + Assert.Equal(10, updatedBalance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Balance_can_increment_and_decrement() { var account = new BankAccount(); @@ -44,24 +42,22 @@ public void Balance_can_increment_and_decrement() account.UpdateBalance(-15); var subtractedBalance = account.Balance; - Assert.That(openingBalance, Is.EqualTo(0)); - Assert.That(addedBalance, Is.EqualTo(10)); - Assert.That(subtractedBalance, Is.EqualTo(-5)); + Assert.Equal(0, openingBalance); + Assert.Equal(10, addedBalance); + Assert.Equal(-5, subtractedBalance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Closed_account_throws_exception_when_checking_balance() { var account = new BankAccount(); account.Open(); account.Close(); - Assert.That(() => account.Balance, Throws.InvalidOperationException); + Assert.Throws(() => account.Balance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Change_account_balance_from_multiple_threads() { var account = new BankAccount(); @@ -84,6 +80,6 @@ public void Change_account_balance_from_multiple_threads() } Task.WaitAll(tasks.ToArray()); - Assert.That(account.Balance, Is.EqualTo(0)); + Assert.Equal(0, account.Balance); } } diff --git a/exercises/beer-song/BeerTest.cs b/exercises/beer-song/BeerTest.cs index d66f4c51b7..cbdb2d6f29 100644 --- a/exercises/beer-song/BeerTest.cs +++ b/exercises/beer-song/BeerTest.cs @@ -1,20 +1,22 @@ -using NUnit.Framework; +using Xunit; public class BeerTests { - [TestCase(8, ExpectedResult = "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n")] - [TestCase(2, ExpectedResult = "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n", Ignore = "Remove to run test case")] - [TestCase(1, ExpectedResult = "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n", Ignore = "Remove to run test case")] - [TestCase(0, ExpectedResult = "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n", Ignore = "Remove to run test case")] - public string Verse(int number) + [Theory] + [InlineData(8, "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n")] + [InlineData(2, "2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n")] + [InlineData(1, "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n")] + [InlineData(0, "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n")] + public void Verse(int number, string expected) { - return Beer.Verse(number); + Assert.Equal(expected, Beer.Verse(number)); } - [TestCase(8, 6, ExpectedResult = "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n\n7 bottles of beer on the wall, 7 bottles of beer.\nTake one down and pass it around, 6 bottles of beer on the wall.\n\n6 bottles of beer on the wall, 6 bottles of beer.\nTake one down and pass it around, 5 bottles of beer on the wall.\n\n", Ignore = "Remove to run test case")] - [TestCase(3, 0, ExpectedResult = "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n\n2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\nNo more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n", Ignore = "Remove to run test case")] - public string Sing(int start, int stop) + [Theory(Skip = "Remove to run test")] + [InlineData(8, 6, "8 bottles of beer on the wall, 8 bottles of beer.\nTake one down and pass it around, 7 bottles of beer on the wall.\n\n7 bottles of beer on the wall, 7 bottles of beer.\nTake one down and pass it around, 6 bottles of beer on the wall.\n\n6 bottles of beer on the wall, 6 bottles of beer.\nTake one down and pass it around, 5 bottles of beer on the wall.\n\n")] + [InlineData(3, 0, "3 bottles of beer on the wall, 3 bottles of beer.\nTake one down and pass it around, 2 bottles of beer on the wall.\n\n2 bottles of beer on the wall, 2 bottles of beer.\nTake one down and pass it around, 1 bottle of beer on the wall.\n\n1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bottles of beer on the wall.\n\nNo more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n\n")] + public void Sing(int start, int stop, string expected) { - return Beer.Sing(start, stop); + Assert.Equal(expected, Beer.Sing(start, stop)); } } \ No newline at end of file diff --git a/exercises/binary-search-tree/BinarySearchTreeTest.cs b/exercises/binary-search-tree/BinarySearchTreeTest.cs index 0d7efb8c38..ebf718d684 100644 --- a/exercises/binary-search-tree/BinarySearchTreeTest.cs +++ b/exercises/binary-search-tree/BinarySearchTreeTest.cs @@ -1,85 +1,77 @@ using System.Linq; -using NUnit.Framework; +using Xunit; public class BinarySearchTreeTest { - [Test] + [Fact] public void Data_is_retained() { var tree = new BinarySearchTree(4); - Assert.That(tree.Value, Is.EqualTo(4)); + Assert.Equal(4, tree.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Inserting_less() { var tree = new BinarySearchTree(4).Add(2); - Assert.That(tree.Value, Is.EqualTo(4)); - Assert.That(tree.Left.Value, Is.EqualTo(2)); + Assert.Equal(4, tree.Value); + Assert.Equal(2, tree.Left.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Inserting_same() { var tree = new BinarySearchTree(4).Add(4); - Assert.That(tree.Value, Is.EqualTo(4)); - Assert.That(tree.Left.Value, Is.EqualTo(4)); + Assert.Equal(4, tree.Value); + Assert.Equal(4, tree.Left.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Inserting_greater() { var tree = new BinarySearchTree(4).Add(5); - Assert.That(tree.Value, Is.EqualTo(4)); - Assert.That(tree.Right.Value, Is.EqualTo(5)); + Assert.Equal(4, tree.Value); + Assert.Equal(5, tree.Right.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Complex_tree() { var tree = new BinarySearchTree(new [] { 4, 2, 6, 1, 3, 7, 5 }); - Assert.That(tree.Value, Is.EqualTo(4)); - Assert.That(tree.Left.Value, Is.EqualTo(2)); - Assert.That(tree.Left.Left.Value, Is.EqualTo(1)); - Assert.That(tree.Left.Right.Value, Is.EqualTo(3)); - Assert.That(tree.Right.Value, Is.EqualTo(6)); - Assert.That(tree.Right.Left.Value, Is.EqualTo(5)); - Assert.That(tree.Right.Right.Value, Is.EqualTo(7)); + Assert.Equal(4, tree.Value); + Assert.Equal(2, tree.Left.Value); + Assert.Equal(1, tree.Left.Left.Value); + Assert.Equal(3, tree.Left.Right.Value); + Assert.Equal(6, tree.Right.Value); + Assert.Equal(5, tree.Right.Left.Value); + Assert.Equal(7, tree.Right.Right.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Iterating_one_element() { var elements = new BinarySearchTree(4).AsEnumerable(); - Assert.That(elements, Is.EqualTo(new [] { 4 })); + Assert.Equal(new [] { 4 }, elements); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Iterating_over_smaller_element() { var elements = new BinarySearchTree(new[] { 4, 2 }).AsEnumerable(); - Assert.That(elements, Is.EqualTo(new[] { 2, 4 })); + Assert.Equal(new[] { 2, 4 }, elements); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Iterating_over_larger_element() { var elements = new BinarySearchTree(new[] { 4, 5 }).AsEnumerable(); - Assert.That(elements, Is.EqualTo(new[] { 4, 5 })); + Assert.Equal(new[] { 4, 5 }, elements); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Iterating_over_complex_element() { var elements = new BinarySearchTree(new[] { 4, 2, 1, 3, 6, 7, 5 }).AsEnumerable(); - Assert.That(elements, Is.EqualTo(new[] { 1, 2, 3, 4, 5, 6, 7 })); + Assert.Equal(new[] { 1, 2, 3, 4, 5, 6, 7 }, elements); } } \ No newline at end of file diff --git a/exercises/binary-search/BinarySearchTest.cs b/exercises/binary-search/BinarySearchTest.cs index a607afe69d..d1d98f49e0 100644 --- a/exercises/binary-search/BinarySearchTest.cs +++ b/exercises/binary-search/BinarySearchTest.cs @@ -1,76 +1,67 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class BinarySearchTest { - [Test] + [Fact] public void Should_return_minus_one_when_an_empty_array_is_searched() { var input = new int[0]; - Assert.That(BinarySearch.Search(input, 6), Is.EqualTo(-1)); + Assert.Equal(-1, BinarySearch.Search(input, 6)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_be_able_to_find_a_value_in_a_single_element_array_with_one_access() { var input = new[] { 6 }; - Assert.That(BinarySearch.Search(input, 6), Is.EqualTo(0)); + Assert.Equal(0, BinarySearch.Search(input, 6)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_return_minus_one_if_a_value_is_less_than_the_element_in_a_single_element_array() { var input = new[] { 94 }; - Assert.That(BinarySearch.Search(input, 6), Is.EqualTo(-1)); + Assert.Equal(-1, BinarySearch.Search(input, 6)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_return_minus_one_if_a_value_is_greater_than_the_element_in_a_single_element_array() { var input = new[] { 94 }; - Assert.That(BinarySearch.Search(input, 602), Is.EqualTo(-1)); + Assert.Equal(-1, BinarySearch.Search(input, 602)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_an_element_in_a_longer_array() { var input = new[] { 6, 67, 123, 345, 456, 457, 490, 2002, 54321, 54322 }; - Assert.That(BinarySearch.Search(input, 2002), Is.EqualTo(7)); + Assert.Equal(7, BinarySearch.Search(input, 2002)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_elements_at_the_beginning_of_an_array() { var input = new[] { 6, 67, 123, 345, 456, 457, 490, 2002, 54321, 54322 }; - Assert.That(BinarySearch.Search(input, 6), Is.EqualTo(0)); + Assert.Equal(0, BinarySearch.Search(input, 6)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_elements_at_the_end_of_an_array() { var input = new[] { 6, 67, 123, 345, 456, 457, 490, 2002, 54321, 54322 }; - Assert.That(BinarySearch.Search(input, 54322), Is.EqualTo(9)); + Assert.Equal(9, BinarySearch.Search(input, 54322)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_return_minus_one_if_a_value_is_less_than_all_elements_in_a_long_array() { var input = new[] { 6, 67, 123, 345, 456, 457, 490, 2002, 54321, 54322 }; - Assert.That(BinarySearch.Search(input, 2), Is.EqualTo(-1)); + Assert.Equal(-1, BinarySearch.Search(input, 2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_return_minus_one_if_a_value_is_greater_than_all_elements_in_a_long_array() { var input = new[] { 6, 67, 123, 345, 456, 457, 490, 2002, 54321, 54322 }; - Assert.That(BinarySearch.Search(input, 54323), Is.EqualTo(-1)); + Assert.Equal(-1, BinarySearch.Search(input, 54323)); } } \ No newline at end of file diff --git a/exercises/bob/BobTest.cs b/exercises/bob/BobTest.cs index 5a4a542d05..1019d9bb18 100644 --- a/exercises/bob/BobTest.cs +++ b/exercises/bob/BobTest.cs @@ -1,130 +1,112 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class BobTest { - [Test] + [Fact] public void Stating_something () { - Assert.That(Bob.Hey("Tom-ay-to, tom-aaaah-to."), Is.EqualTo("Whatever.")); + Assert.Equal("Whatever.", Bob.Hey("Tom-ay-to, tom-aaaah-to.")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Shouting () { - Assert.That(Bob.Hey("WATCH OUT!"), Is.EqualTo("Whoa, chill out!")); + Assert.Equal("Whoa, chill out!", Bob.Hey("WATCH OUT!")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Asking_a_question () { - Assert.That(Bob.Hey("Does this cryogenic chamber make me look fat?"), Is.EqualTo("Sure.")); + Assert.Equal("Sure.", Bob.Hey("Does this cryogenic chamber make me look fat?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Asking_a_question_with_a_trailing_space() { - Assert.That(Bob.Hey("Do I like my spacebar too much? "), Is.EqualTo("Sure.")); + Assert.Equal("Sure.", Bob.Hey("Do I like my spacebar too much? ")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Asking_a_numeric_question () { - Assert.That(Bob.Hey("You are, what, like 15?"), Is.EqualTo("Sure.")); + Assert.Equal("Sure.", Bob.Hey("You are, what, like 15?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Talking_forcefully () { - Assert.That(Bob.Hey("Let's go make out behind the gym!"), Is.EqualTo("Whatever.")); + Assert.Equal("Whatever.", Bob.Hey("Let's go make out behind the gym!")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Using_acronyms_in_regular_search () { - Assert.That(Bob.Hey("It's OK if you don't want to go to the DMV."), Is.EqualTo("Whatever.")); + Assert.Equal("Whatever.", Bob.Hey("It's OK if you don't want to go to the DMV.")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Forceful_questions () { - Assert.That(Bob.Hey("WHAT THE HELL WERE YOU THINKING?"), Is.EqualTo("Whoa, chill out!")); + Assert.Equal("Whoa, chill out!", Bob.Hey("WHAT THE HELL WERE YOU THINKING?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Shouting_numbers () { - Assert.That(Bob.Hey("1, 2, 3 GO!"), Is.EqualTo("Whoa, chill out!")); + Assert.Equal("Whoa, chill out!", Bob.Hey("1, 2, 3 GO!")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Only_numbers () { - Assert.That(Bob.Hey("1, 2, 3"), Is.EqualTo("Whatever.")); + Assert.Equal("Whatever.", Bob.Hey("1, 2, 3")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Question_with_only_numbers () { - Assert.That(Bob.Hey("4?"), Is.EqualTo("Sure.")); + Assert.Equal("Sure.", Bob.Hey("4?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Shouting_with_special_characters () { - Assert.That(Bob.Hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!"), Is.EqualTo("Whoa, chill out!")); + Assert.Equal("Whoa, chill out!", Bob.Hey("ZOMG THE %^*@#$(*^ ZOMBIES ARE COMING!!11!!1!")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Shouting_with_no_exclamation_mark () { - Assert.That(Bob.Hey("I HATE YOU"), Is.EqualTo("Whoa, chill out!")); + Assert.Equal("Whoa, chill out!", Bob.Hey("I HATE YOU")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Statement_containing_question_mark () { - Assert.That(Bob.Hey("Ending with ? means a question."), Is.EqualTo("Whatever.")); + Assert.Equal("Whatever.", Bob.Hey("Ending with ? means a question.")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Prattling_on () { - Assert.That(Bob.Hey("Wait! Hang on. Are you going to be OK?"), Is.EqualTo("Sure.")); + Assert.Equal("Sure.", Bob.Hey("Wait! Hang on. Are you going to be OK?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Silence () { - Assert.That(Bob.Hey(""), Is.EqualTo("Fine. Be that way!")); + Assert.Equal("Fine. Be that way!", Bob.Hey("")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Prolonged_silence () { - Assert.That(Bob.Hey(" "), Is.EqualTo("Fine. Be that way!")); + Assert.Equal("Fine. Be that way!", Bob.Hey(" ")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_line_question () { - Assert.That(Bob.Hey("Does this cryogenic chamber make me look fat?\nno"), Is.EqualTo("Whatever.")); + Assert.Equal("Whatever.", Bob.Hey("Does this cryogenic chamber make me look fat?\nno")); } } diff --git a/exercises/book-store/BookStoreTest.cs b/exercises/book-store/BookStoreTest.cs index 8ec73c56e4..4faed66a6e 100644 --- a/exercises/book-store/BookStoreTest.cs +++ b/exercises/book-store/BookStoreTest.cs @@ -1,91 +1,79 @@ using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; -[TestFixture] public class BookStoreTest { - [Test] + [Fact] public void Basket_with_single_book() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1)), Is.EqualTo(8)); + Assert.Equal(8, BookStore.CalculateTotalCost(MakeList(1))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_two_of_same_book() { - Assert.That(BookStore.CalculateTotalCost(MakeList(2, 2)), Is.EqualTo(16)); + Assert.Equal(16, BookStore.CalculateTotalCost(MakeList(2, 2))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_basket() { - Assert.That(BookStore.CalculateTotalCost(MakeList()), Is.EqualTo(0)); + Assert.Equal(0, BookStore.CalculateTotalCost(MakeList())); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_two_different_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 2)), Is.EqualTo(15.2)); + Assert.Equal(15.2, BookStore.CalculateTotalCost(MakeList(1, 2))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_three_different_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 2, 3)), Is.EqualTo(21.6)); + Assert.Equal(21.6, BookStore.CalculateTotalCost(MakeList(1, 2, 3))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_four_different_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 2, 3, 4)), Is.EqualTo(25.6)); + Assert.Equal(25.6, BookStore.CalculateTotalCost(MakeList(1, 2, 3, 4))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_five_different_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 2, 3, 4, 5)), Is.EqualTo(30)); + Assert.Equal(30, BookStore.CalculateTotalCost(MakeList(1, 2, 3, 4, 5))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_eight_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 5)), Is.EqualTo(51.20)); + Assert.Equal(51.20, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 5))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_nine_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5)), Is.EqualTo(55.60)); + Assert.Equal(55.60, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_ten_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5)), Is.EqualTo(60)); + Assert.Equal(60, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_eleven_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1)), Is.EqualTo(68)); + Assert.Equal(68, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basket_with_twelve_books() { - Assert.That(BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2)), Is.EqualTo(75.20)); + Assert.Equal(75.20, BookStore.CalculateTotalCost(MakeList(1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2))); } private static List MakeList(params int[] values) diff --git a/exercises/bowling/BowlingTest.cs b/exercises/bowling/BowlingTest.cs index b8725aaebc..3441476f98 100644 --- a/exercises/bowling/BowlingTest.cs +++ b/exercises/bowling/BowlingTest.cs @@ -1,221 +1,198 @@ using System.Collections.Generic; -using NUnit.Framework; +using Xunit; public class BowlingTest { - [Test] + [Fact] public void Should_be_able_to_score_a_game_with_all_zeros() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(0)); + Assert.Equal(0, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_be_able_to_score_a_game_with_no_strikes_or_spares() { var rolls = new[] { 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6, 3, 6 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(90)); + Assert.Equal(90, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_spare_followed_by_zeros_is_worth_ten_points() { var rolls = new[] { 6, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(10)); + Assert.Equal(10, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Points_scored_in_the_roll_after_a_spare_are_counted_twice() { var rolls = new[] { 6, 4, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(16)); + Assert.Equal(16, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Consecutive_spares_each_get_a_one_roll_bonus() { var rolls = new[] { 5, 5, 3, 7, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(31)); + Assert.Equal(31, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_spare_in_the_last_frame_gets_a_one_roll_bonus_that_is_counted_once() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 7 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(17)); + Assert.Equal(17, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_strike_earns_ten_points_in_frame_with_a_single_roll() { var rolls = new[] { 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(10)); + Assert.Equal(10, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Points_scored_in_the_two_rolls_after_a_strike_are_counted_twice_as_a_bonus() { var rolls = new[] { 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(26)); + Assert.Equal(26, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Consecutive_strikes_each_get_the_two_roll_bonus() { var rolls = new[] { 10, 10, 10, 5, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(81)); + Assert.Equal(81, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_strike_in_the_last_frame_gets_a_two_roll_bonus_that_is_counted_once() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 1 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(18)); + Assert.Equal(18, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rolling_a_spare_with_the_two_roll_bonus_does_not_get_a_bonus_roll() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 7, 3 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(20)); + Assert.Equal(20, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Strikes_with_the_two_roll_bonus_do_not_get_bonus_rolls() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10, 10 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(30)); + Assert.Equal(30, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_strike_with_the_one_roll_bonus_after_a_spare_in_the_last_frame_does_not_get_a_bonus() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3, 10 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(20)); + Assert.Equal(20, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void All_strikes_is_a_perfect_game() { var rolls = new[] { 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.EqualTo(300)); + Assert.Equal(300, game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rolls_can_not_score_negative_points() { var rolls = new[] { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_roll_can_not_score_more_than_10_points() { var rolls = new[] { 11, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_rolls_in_a_frame_can_not_score_more_than_10_points() { var rolls = new[] { 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_bonus_rolls_after_a_strike_in_the_last_frame_can_not_score_more_than_10_points() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 5, 6 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void An_unstarted_game_can_not_be_scored() { var rolls = new int[0]; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void An_incomplete_game_can_not_be_scored() { var rolls = new[] { 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_game_with_more_than_ten_frames_can_not_be_scored() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Both_bonus_rolls_for_a_strike_in_the_last_frame_must_be_rolled_before_score_can_be_calculated() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10, 10 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Bonus_roll_for_a_spare_in_the_last_frame_must_be_rolled_before_score_can_be_calculated() { var rolls = new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 3 }; var game = RollMany(rolls, new BowlingGame()); - Assert.That(game.Score(), Is.Null); + Assert.Null(game.Score()); } private static BowlingGame RollMany(IEnumerable rolls, BowlingGame game) diff --git a/exercises/bracket-push/BracketPushTest.cs b/exercises/bracket-push/BracketPushTest.cs index a91f9bdd09..79cf4d3c67 100644 --- a/exercises/bracket-push/BracketPushTest.cs +++ b/exercises/bracket-push/BracketPushTest.cs @@ -1,99 +1,88 @@ -using NUnit.Framework; +using Xunit; public class BracketPushTest { - [Test] + [Fact] public void Paired_square_brackets() { const string actual = "[]"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_string() { const string actual = ""; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Unpaired_brackets() { const string actual = "[["; - Assert.That(BracketPush.Matched(actual), Is.False); + Assert.False(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Wrong_ordered_brackets() { const string actual = "}{"; - Assert.That(BracketPush.Matched(actual), Is.False); + Assert.False(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Paired_with_whitespace() { const string actual = "{ }"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Simple_nested_brackets() { const string actual = "{[]}"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Several_paired_brackets() { const string actual = "{}[]"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Paired_and_nested_brackets() { const string actual = "([{}({}[])])"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Unpaired_and_nested_brackets() { const string actual = "([{])"; - Assert.That(BracketPush.Matched(actual), Is.False); + Assert.False(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Paired_and_wrong_nested_brackets() { const string actual = "[({]})"; - Assert.That(BracketPush.Matched(actual), Is.False); + Assert.False(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Math_expression() { const string actual = "(((185 + 223.85) * 15) - 543)/2"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Complex_latex_expression() { const string actual = "\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)"; - Assert.That(BracketPush.Matched(actual), Is.True); + Assert.True(BracketPush.Matched(actual)); } } \ No newline at end of file diff --git a/exercises/change/ChangeTest.cs b/exercises/change/ChangeTest.cs index d34a4086be..b7808ce2ad 100644 --- a/exercises/change/ChangeTest.cs +++ b/exercises/change/ChangeTest.cs @@ -1,69 +1,63 @@ using System; -using NUnit.Framework; +using Xunit; public class ChangeTest { - [Test] + [Fact] public void Single_coin_change() { var actual = new[] { 1, 5, 10, 25, 100 }; var target = 25; var expected = new[] { 25 }; - Assert.That(Change.Calculate(target, actual), Is.EqualTo(expected)); + Assert.Equal(expected, Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_coin_change() { var actual = new[] { 1, 5, 10, 25, 100 }; var target = 15; var expected = new[] { 5, 10 }; - Assert.That(Change.Calculate(target, actual), Is.EqualTo(expected)); + Assert.Equal(expected, Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Change_with_Lilliputian_Coins() { var actual = new[] { 1, 4, 15, 20, 50 }; var target = 23; var expected = new[] { 4, 4, 15 }; - Assert.That(Change.Calculate(target, actual), Is.EqualTo(expected)); + Assert.Equal(expected, Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Change_with_Lower_Elbonia_Coins() { var actual = new[] { 1, 5, 10, 21, 25 }; var target = 63; var expected = new[] { 21, 21, 21 }; - Assert.That(Change.Calculate(target, actual), Is.EqualTo(expected)); + Assert.Equal(expected, Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Large_target_values() { var actual = new[] { 1, 2, 5, 10, 20, 50, 100 }; var target = 999; var expected = new[] { 2, 2, 5, 20, 20, 50, 100, 100, 100, 100, 100, 100, 100, 100, 100 }; - Assert.That(Change.Calculate(target, actual), Is.EqualTo(expected)); + Assert.Equal(expected, Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void No_coins_make_0_change() { var actual = new[] { 1, 5, 10, 21, 25 }; var target = 0; var expected = new int[0]; - Assert.That(Change.Calculate(target, actual), Is.EqualTo(expected)); + Assert.Equal(expected, Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Error_testing_for_change_smaller_than_the_smallest_of_coins() { var actual = new[] { 5, 10 }; @@ -71,8 +65,7 @@ public void Error_testing_for_change_smaller_than_the_smallest_of_coins() Assert.Throws(() => Change.Calculate(target, actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cannot_find_negative_change_values() { var actual = new[] { 1, 2, 5 }; diff --git a/exercises/circular-buffer/CircularBufferTest.cs b/exercises/circular-buffer/CircularBufferTest.cs index 768f33bcb0..4131bdeff2 100644 --- a/exercises/circular-buffer/CircularBufferTest.cs +++ b/exercises/circular-buffer/CircularBufferTest.cs @@ -1,20 +1,20 @@ -using NUnit.Framework; +using System; +using Xunit; public class CircularBufferTest { - [Test] + [Fact] public void Write_and_read_back_one_item() { var buffer = new CircularBuffer(1); buffer.Write('1'); var val = buffer.Read(); - Assert.That(val, Is.EqualTo('1')); - Assert.That(() => buffer.Read(), Throws.Exception); + Assert.Equal('1', val); + Assert.Throws(() => buffer.Read()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Write_and_read_back_multiple_items() { var buffer = new CircularBuffer(2); @@ -24,13 +24,12 @@ public void Write_and_read_back_multiple_items() var val1 = buffer.Read(); var val2 = buffer.Read(); - Assert.That(val1, Is.EqualTo('1')); - Assert.That(val2, Is.EqualTo('2')); - Assert.That(() => buffer.Read(), Throws.Exception); + Assert.Equal('1', val1); + Assert.Equal('2', val2); + Assert.Throws(() => buffer.Read()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Clearing_buffer() { var buffer = new CircularBuffer(3); @@ -40,7 +39,7 @@ public void Clearing_buffer() buffer.Clear(); - Assert.That(() => buffer.Read(), Throws.Exception); + Assert.Throws(() => buffer.Read()); buffer.Write('1'); buffer.Write('2'); @@ -49,12 +48,11 @@ public void Clearing_buffer() buffer.Write('3'); var val2 = buffer.Read(); - Assert.That(val1, Is.EqualTo('1')); - Assert.That(val2, Is.EqualTo('2')); + Assert.Equal('1', val1); + Assert.Equal('2', val2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Alternate_write_and_read() { var buffer = new CircularBuffer(2); @@ -63,12 +61,11 @@ public void Alternate_write_and_read() buffer.Write('2'); var val2 = buffer.Read(); - Assert.That(val1, Is.EqualTo('1')); - Assert.That(val2, Is.EqualTo('2')); + Assert.Equal('1', val1); + Assert.Equal('2', val2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reads_back_oldest_item() { var buffer1 = new CircularBuffer(3); @@ -79,23 +76,21 @@ public void Reads_back_oldest_item() buffer1.Write('3'); var val2 = buffer1.Read(); var val3 = buffer1.Read(); - Assert.That(val2, Is.EqualTo('2')); - Assert.That(val3, Is.EqualTo('3')); + Assert.Equal('2', val2); + Assert.Equal('3', val3); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Writing_to_a_full_buffer_throws_an_exception() { var buffer = new CircularBuffer(2); buffer.Write('1'); buffer.Write('2'); - Assert.That(() => buffer.Write('A'), Throws.Exception); + Assert.Throws(() => buffer.Write('A')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Overwriting_oldest_item_in_a_full_buffer() { var buffer = new CircularBuffer(2); @@ -106,13 +101,12 @@ public void Overwriting_oldest_item_in_a_full_buffer() var val1 = buffer.Read(); var val2 = buffer.Read(); - Assert.That(val1, Is.EqualTo('2')); - Assert.That(val2, Is.EqualTo('A')); - Assert.That(() => buffer.Read(), Throws.Exception); + Assert.Equal('2', val1); + Assert.Equal('A', val2); + Assert.Throws(() => buffer.Read()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Forced_writes_to_non_full_buffer_should_behave_like_writes() { var buffer = new CircularBuffer(2); @@ -122,13 +116,12 @@ public void Forced_writes_to_non_full_buffer_should_behave_like_writes() var val1 = buffer.Read(); var val2 = buffer.Read(); - Assert.That(val1, Is.EqualTo('1')); - Assert.That(val2, Is.EqualTo('2')); - Assert.That(() => buffer.Read(), Throws.Exception); + Assert.Equal('1', val1); + Assert.Equal('2', val2); + Assert.Throws(() => buffer.Read()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Alternate_read_and_write_into_buffer_overflow() { var buffer = new CircularBuffer(5); @@ -155,11 +148,11 @@ public void Alternate_read_and_write_into_buffer_overflow() var val7 = buffer.Read(); var val8 = buffer.Read(); - Assert.That(val4, Is.EqualTo('6')); - Assert.That(val5, Is.EqualTo('7')); - Assert.That(val6, Is.EqualTo('8')); - Assert.That(val7, Is.EqualTo('A')); - Assert.That(val8, Is.EqualTo('B')); - Assert.That(() => buffer.Read(), Throws.Exception); + Assert.Equal('6', val4); + Assert.Equal('7', val5); + Assert.Equal('8', val6); + Assert.Equal('A', val7); + Assert.Equal('B', val8); + Assert.Throws(() => buffer.Read()); } } \ No newline at end of file diff --git a/exercises/clock/ClockTest.cs b/exercises/clock/ClockTest.cs index e5e4a9e9f4..634d880233 100644 --- a/exercises/clock/ClockTest.cs +++ b/exercises/clock/ClockTest.cs @@ -1,127 +1,114 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class ClockTest { - [TestCase(8, "08:00")] - [TestCase(9, "09:00")] + [Theory] + [InlineData(8, "08:00")] + [InlineData(9, "09:00")] public void Prints_the_hour(int hours, string expected) { - Assert.That(new Clock(hours).ToString(), Is.EqualTo(expected)); + Assert.Equal(expected, new Clock(hours).ToString()); } - [Ignore("Remove to run test")] - [TestCase(11, 9, "11:09")] - [TestCase(11, 19, "11:19")] + [Theory(Skip = "Remove to run test")] + [InlineData(11, 9, "11:09")] + [InlineData(11, 19, "11:19")] public void Prints_past_the_hour(int hours, int minutes, string expected) { - Assert.That(new Clock(hours, minutes).ToString(), Is.EqualTo(expected)); + Assert.Equal(expected, new Clock(hours, minutes).ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_minutes() { var clock = new Clock(10).Add(3); - Assert.That(clock.ToString(), Is.EqualTo("10:03")); + Assert.Equal("10:03", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_over_an_hour() { var clock = new Clock(10).Add(63); - Assert.That(clock.ToString(), Is.EqualTo("11:03")); + Assert.Equal("11:03", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_over_more_than_one_day() { var clock = new Clock(10).Add(7224); - Assert.That(clock.ToString(), Is.EqualTo("10:24")); + Assert.Equal("10:24", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_subtract_minutes() { var clock = new Clock(10, 3).Subtract(3); - Assert.That(clock.ToString(), Is.EqualTo("10:00")); + Assert.Equal("10:00", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_subtract_to_previous_hour() { var clock = new Clock(10, 3).Subtract(30); - Assert.That(clock.ToString(), Is.EqualTo("09:33")); + Assert.Equal("09:33", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_subtract_over_an_hour() { var clock = new Clock(10, 3).Subtract(70); - Assert.That(clock.ToString(), Is.EqualTo("08:53")); + Assert.Equal("08:53", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Wraps_around_midnight() { var clock = new Clock(23, 59).Add(2); - Assert.That(clock.ToString(), Is.EqualTo("00:01")); + Assert.Equal("00:01", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Wraps_around_midnight_backwards() { var clock = new Clock(0, 1).Subtract(2); - Assert.That(clock.ToString(), Is.EqualTo("23:59")); + Assert.Equal("23:59", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Midnight_is_zero_hundred_hours() { var clock = new Clock(24); - Assert.That(clock.ToString(), Is.EqualTo("00:00")); + Assert.Equal("00:00", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sixty_minutes_is_next_hour() { var clock = new Clock(1, 60); - Assert.That(clock.ToString(), Is.EqualTo("02:00")); + Assert.Equal("02:00", clock.ToString()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Clocks_with_same_time_are_equal() { var clock1 = new Clock(14, 30); var clock2 = new Clock(14, 30); - Assert.That(clock1, Is.EqualTo(clock2)); + Assert.Equal(clock2, clock1); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Clocks_with_different_time_are_not_equal() { var clock1 = new Clock(15, 30); var clock2 = new Clock(14, 30); - Assert.That(clock1, Is.Not.EqualTo(clock2)); + Assert.NotEqual(clock2, clock1); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Overflown_clocks_with_same_time_are_equal() { var clock1 = new Clock(14, 30); var clock2 = new Clock(38, 30); - Assert.That(clock1, Is.EqualTo(clock2)); + Assert.Equal(clock2, clock1); } } \ No newline at end of file diff --git a/exercises/connect/ConnectTest.cs b/exercises/connect/ConnectTest.cs index 701720ed8c..b90f8015d9 100644 --- a/exercises/connect/ConnectTest.cs +++ b/exercises/connect/ConnectTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using Xunit; using System.Linq; public class ConnectTest @@ -8,7 +8,7 @@ private static string MakeBoard(string[] board) return string.Join("\n", board.Select(x => x.Replace(" ", ""))); } - [Test] + [Fact] public void Empty_board_has_no_winner() { var lines = new[] @@ -20,29 +20,26 @@ public void Empty_board_has_no_winner() " . . . . ." }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.None)); + Assert.Equal(Connect.Winner.None, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_by_one_board_with_black_stone() { var lines = new[] { "X" }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.Black)); + Assert.Equal(Connect.Winner.Black, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_by_one_board_with_white_stone() { var lines = new[] { "O" }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.White)); + Assert.Equal(Connect.Winner.White, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Convoluted_path() { var lines = new[] @@ -54,11 +51,10 @@ public void Convoluted_path() " O O O O O" }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.Black)); + Assert.Equal(Connect.Winner.Black, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rectangle_black_wins() { var lines = new[] @@ -70,11 +66,10 @@ public void Rectangle_black_wins() " . O X ." }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.Black)); + Assert.Equal(Connect.Winner.Black, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rectangle_white_wins() { var lines = new[] @@ -86,11 +81,10 @@ public void Rectangle_white_wins() " . O X ." }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.White)); + Assert.Equal(Connect.Winner.White, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Spiral_black_wins() { var lines = new[] @@ -106,11 +100,10 @@ public void Spiral_black_wins() "XXXXXXXXO" }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.Black)); + Assert.Equal(Connect.Winner.Black, board.Result()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Spiral_nobody_wins() { var lines = new[] @@ -126,6 +119,6 @@ public void Spiral_nobody_wins() "XXXXXXXXO" }; var board = new Connect(MakeBoard(lines)); - Assert.That(board.Result(), Is.EqualTo(Connect.Winner.None)); + Assert.Equal(Connect.Winner.None, board.Result()); } } \ No newline at end of file diff --git a/exercises/crypto-square/CryptoSquareTest.cs b/exercises/crypto-square/CryptoSquareTest.cs index 5348ff0337..6db077fdb7 100644 --- a/exercises/crypto-square/CryptoSquareTest.cs +++ b/exercises/crypto-square/CryptoSquareTest.cs @@ -1,132 +1,116 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class CryptoSquareTest { - [Test] + [Fact] public void Strange_characters_are_stripped_during_normalization() { var crypto = new Crypto("s#$%^&plunk"); - Assert.That(crypto.NormalizePlaintext, Is.EqualTo("splunk")); + Assert.Equal("splunk", crypto.NormalizePlaintext); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Letters_are_lowercased_during_normalization() { var crypto = new Crypto("WHOA HEY!"); - Assert.That(crypto.NormalizePlaintext, Is.EqualTo("whoahey")); + Assert.Equal("whoahey", crypto.NormalizePlaintext); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Numbers_are_kept_during_normalization() { var crypto = new Crypto("1, 2, 3, GO!"); - Assert.That(crypto.NormalizePlaintext, Is.EqualTo("123go")); + Assert.Equal("123go", crypto.NormalizePlaintext); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Smallest_square_size_is_2() { var crypto = new Crypto("1234"); - Assert.That(crypto.Size, Is.EqualTo(2)); + Assert.Equal(2, crypto.Size); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Size_of_text_whose_length_is_a_perfect_square_is_its_square_root() { var crypto = new Crypto("123456789"); - Assert.That(crypto.Size, Is.EqualTo(3)); + Assert.Equal(3, crypto.Size); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Size_of_text_whose_length_is_not_a_perfect_square_is_next_biggest_square_root() { var crypto = new Crypto("123456789abc"); - Assert.That(crypto.Size, Is.EqualTo(4)); + Assert.Equal(4, crypto.Size); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Size_is_determined_by_normalized_text() { var crypto = new Crypto("Oh hey, this is nuts!"); - Assert.That(crypto.Size, Is.EqualTo(4)); + Assert.Equal(4, crypto.Size); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Segments_are_split_by_square_size() { var crypto = new Crypto("Never vex thine heart with idle woes"); - Assert.That(crypto.PlaintextSegments(), Is.EqualTo(new[] { "neverv", "exthin", "eheart", "withid", "lewoes" })); + Assert.Equal(new[] { "neverv", "exthin", "eheart", "withid", "lewoes" }, crypto.PlaintextSegments()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Segments_are_split_by_square_size_until_text_runs_out() { var crypto = new Crypto("ZOMG! ZOMBIES!!!"); - Assert.That(crypto.PlaintextSegments(), Is.EqualTo(new[] { "zomg", "zomb", "ies" })); + Assert.Equal(new[] { "zomg", "zomb", "ies" }, crypto.PlaintextSegments()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Ciphertext_combines_text_by_column() { var crypto = new Crypto("First, solve the problem. Then, write the code."); - Assert.That(crypto.Ciphertext(), Is.EqualTo("foeewhilpmrervrticseohtottbeedshlnte")); + Assert.Equal("foeewhilpmrervrticseohtottbeedshlnte", crypto.Ciphertext()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Ciphertext_skips_cells_with_no_text() { var crypto = new Crypto("Time is an illusion. Lunchtime doubly so."); - Assert.That(crypto.Ciphertext(), Is.EqualTo("tasneyinicdsmiohooelntuillibsuuml")); + Assert.Equal("tasneyinicdsmiohooelntuillibsuuml", crypto.Ciphertext()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Normalized_ciphertext_is_split_by_height_of_square() { var crypto = new Crypto("Vampires are people too!"); - Assert.That(crypto.NormalizeCiphertext(), Is.EqualTo("vrel aepe mset paoo irpo")); + Assert.Equal("vrel aepe mset paoo irpo", crypto.NormalizeCiphertext()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Normalized_ciphertext_not_exactly_divisible_by_5_spills_into_a_smaller_segment() { var crypto = new Crypto("Madness, and then illumination."); - Assert.That(crypto.NormalizeCiphertext(), Is.EqualTo("msemo aanin dnin ndla etlt shui")); + Assert.Equal("msemo aanin dnin ndla etlt shui", crypto.NormalizeCiphertext()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Normalized_ciphertext_is_split_into_segements_of_correct_size() { var crypto = new Crypto("If man was meant to stay on the ground god would have given us roots"); - Assert.That(crypto.NormalizeCiphertext(), Is.EqualTo("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau")); + Assert.Equal("imtgdvs fearwer mayoogo anouuio ntnnlvt wttddes aohghn sseoau", crypto.NormalizeCiphertext()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Normalized_ciphertext_is_split_into_segements_of_correct_size_with_punctuation() { var crypto = new Crypto("Have a nice day. Feed the dog & chill out!"); - Assert.That(crypto.NormalizeCiphertext(), Is.EqualTo("hifei acedl veeol eddgo aatcu nyhht")); + Assert.Equal("hifei acedl veeol eddgo aatcu nyhht", crypto.NormalizeCiphertext()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Normalized_ciphertext_is_split_into_segements_of_correct_size_when_just_less_than_full_square() { var crypto = new Crypto("I am"); - Assert.That(crypto.NormalizeCiphertext(), Is.EqualTo("im a")); + Assert.Equal("im a", crypto.NormalizeCiphertext()); } } \ No newline at end of file diff --git a/exercises/custom-set/CustomSetTest.cs b/exercises/custom-set/CustomSetTest.cs index 67091b5c62..f30fb22d59 100644 --- a/exercises/custom-set/CustomSetTest.cs +++ b/exercises/custom-set/CustomSetTest.cs @@ -1,348 +1,312 @@ -using NUnit.Framework; +using Xunit; public class CustomSetTest { - [Test] + [Fact] public void Sets_with_no_elements_are_empty() { var actual = new CustomSet(); - Assert.That(actual.IsEmpty(), Is.True); + Assert.True(actual.IsEmpty()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sets_with_elements_are_not_empty() { var actual = new CustomSet(1); - Assert.That(actual.IsEmpty(), Is.False); + Assert.False(actual.IsEmpty()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Nothing_is_contained_in_an_empty_set() { var actual = new CustomSet(); - Assert.That(actual.Contains(1), Is.False); + Assert.False(actual.Contains(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Detect_if_the_element_is_in_the_set() { var actual = new CustomSet(new[] { 1, 2, 3 }); - Assert.That(actual.Contains(1), Is.True); + Assert.True(actual.Contains(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Detect_if_the_element_is_not_in_the_set() { var actual = new CustomSet(new[] { 1, 2, 3 }); - Assert.That(actual.Contains(4), Is.False); + Assert.False(actual.Contains(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Add_to_empty_set() { var actual = new CustomSet().Insert(3); var expected = new CustomSet(new[] { 3 }); - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.True(expected.Equals(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Add_to_non_empty_set() { var actual = new CustomSet(new[] { 1, 2, 4 }).Insert(3); var expected = new CustomSet(new[] { 1, 2, 3, 4 }); - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.True(expected.Equals(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Adding_an_existing_element_does_not_change_the_set() { var actual = new CustomSet(new[] { 1, 2, 3 }); actual.Insert(3); var expected = new CustomSet(new[] { 1, 2, 3 }); - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.True(expected.Equals(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_set_is_a_subset_of_another_empty_set() { var left = new CustomSet(); var right = new CustomSet(); - Assert.That(left.IsSubsetOf(right), Is.True); + Assert.True(left.IsSubsetOf(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_set_is_a_subset_of_non_empty_set() { var left = new CustomSet(); var right = new CustomSet(1); - Assert.That(left.IsSubsetOf(right), Is.True); + Assert.True(left.IsSubsetOf(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Non_empty_set_is_not_a_subset_of_empty_set() { var left = new CustomSet(1); var right = new CustomSet(); - Assert.That(left.IsSubsetOf(right), Is.False); + Assert.False(left.IsSubsetOf(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Set_is_a_subset_of_set_with_exact_same_elements() { var left = new CustomSet(new[] { 1, 2, 3 }); var right = new CustomSet(new[] { 1, 2, 3 }); - Assert.That(left.IsSubsetOf(right), Is.True); + Assert.True(left.IsSubsetOf(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Set_is_a_subset_of_larger_set_with_same_elements() { var left = new CustomSet(new[] { 1, 2, 3 }); var right = new CustomSet(new[] { 4, 1, 2, 3 }); - Assert.That(left.IsSubsetOf(right), Is.True); + Assert.True(left.IsSubsetOf(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Set_is_not_a_subset_of_set_that_does_not_contain_its_elements() { var left = new CustomSet(new[] { 1, 2, 3 }); var right = new CustomSet(new[] { 4, 1, 3 }); - Assert.That(left.IsSubsetOf(right), Is.False); + Assert.False(left.IsSubsetOf(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void The_empty_set_is_disjoint_with_itself() { var left = new CustomSet(); var right = new CustomSet(); - Assert.That(left.IsDisjointFrom(right), Is.True); + Assert.True(left.IsDisjointFrom(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_set_is_disjoint_with_non_empty_set() { var left = new CustomSet(); var right = new CustomSet(1); - Assert.That(left.IsDisjointFrom(right), Is.True); + Assert.True(left.IsDisjointFrom(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Non_empty_set_is_disjoint_with_empty_set() { var left = new CustomSet(1); var right = new CustomSet(); - Assert.That(left.IsDisjointFrom(right), Is.True); + Assert.True(left.IsDisjointFrom(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sets_are_not_disjoint_if_they_share_an_element() { var left = new CustomSet(new[] { 1, 2 }); var right = new CustomSet(new[] { 2, 3 }); - Assert.That(left.IsDisjointFrom(right), Is.False); + Assert.False(left.IsDisjointFrom(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sets_are_disjoint_if_they_share_no_elements() { var left = new CustomSet(new[] { 1, 2 }); var right = new CustomSet(new[] { 3, 4 }); - Assert.That(left.IsDisjointFrom(right), Is.True); + Assert.True(left.IsDisjointFrom(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Intersection_of_two_empty_sets_is_an_empty_set() { var left = new CustomSet(); var right = new CustomSet(); var expected = new CustomSet(); - Assert.That(left.Intersection(right), Is.EquivalentTo(expected)); + Assert.True(left.Intersection(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Intersection_of_an_empty_set_and_non_empty_set_is_an_empty_set() { var left = new CustomSet(); var right = new CustomSet(new[] { 3, 2, 5 }); var expected = new CustomSet(); - Assert.That(left.Intersection(right), Is.EquivalentTo(expected)); + Assert.True(left.Intersection(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Intersection_of_a_non_empty_set_and_an_empty_set_is_an_empty_set() { var left = new CustomSet(new[] { 1, 2, 3, 4 }); var right = new CustomSet(); var expected = new CustomSet(); - Assert.That(left.Intersection(right), Is.EquivalentTo(expected)); + Assert.True(left.Intersection(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Intersection_of_two_sets_with_no_shared_elements_is_an_empty_set() { var left = new CustomSet(new[] { 1, 2, 3 }); var right = new CustomSet(new[] { 4, 5, 6 }); var expected = new CustomSet(); - Assert.That(left.Intersection(right), Is.EquivalentTo(expected)); + Assert.True(left.Intersection(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Intersection_of_two_sets_with_shared_elements_is_a_set_of_the_shared_elements() { var left = new CustomSet(new[] { 1, 2, 3, 4 }); var right = new CustomSet(new[] { 3, 2, 5 }); var expected = new CustomSet(new[] { 2, 3 }); - Assert.That(left.Intersection(right), Is.EquivalentTo(expected)); + Assert.True(left.Intersection(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Difference_of_two_empty_sets_is_an_empty_set() { var left = new CustomSet(); var right = new CustomSet(); var expected = new CustomSet(); - Assert.That(left.Difference(right), Is.EquivalentTo(expected)); + Assert.True(left.Difference(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Difference_of_an_empty_set_and_non_empty_set_is_an_empty_set() { var left = new CustomSet(); var right = new CustomSet(new[] { 3, 2, 5 }); var expected = new CustomSet(); - Assert.That(left.Difference(right), Is.EquivalentTo(expected)); + Assert.True(left.Difference(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Difference_of_a_non_empty_set_and_an_empty_set_is_an_empty_set() { var left = new CustomSet(new[] { 1, 2, 3, 4 }); var right = new CustomSet(); var expected = new CustomSet(new[] { 1, 2, 3, 4 }); - Assert.That(left.Difference(right), Is.EquivalentTo(expected)); + Assert.True(left.Difference(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Difference_of_two_non_empty_sets_is_a_set_of_elements_that_are_only_in_the_first_set() { var left = new CustomSet(new[] { 3, 2, 1 }); var right = new CustomSet(new[] { 2, 4 }); var expected = new CustomSet(new[] { 1, 3 }); - Assert.That(left.Difference(right), Is.EquivalentTo(expected)); + Assert.True(left.Difference(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Union_of_two_empty_sets_is_an_empty_set() { var left = new CustomSet(); var right = new CustomSet(); var expected = new CustomSet(); - Assert.That(left.Union(right), Is.EquivalentTo(expected)); + Assert.True(left.Union(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Union_of_an_empty_set_and_non_empty_set_is_the_non_empty_set() { var left = new CustomSet(); var right = new CustomSet(new[] { 2 }); var expected = new CustomSet(new[] { 2 }); - Assert.That(left.Union(right), Is.EquivalentTo(expected)); + Assert.True(left.Union(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Union_of_a_non_empty_set_and_empty_set_is_the_non_empty_set() { var left = new CustomSet(new[] { 1, 3 }); var right = new CustomSet(); var expected = new CustomSet(new[] { 1, 3 }); - Assert.That(left.Union(right), Is.EquivalentTo(expected)); + Assert.True(left.Union(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Union_of_non_empty_sets_contains_all_unique_elements() { var left = new CustomSet(new[] { 1, 3 }); var right = new CustomSet(new[] { 2, 3 }); var expected = new CustomSet(new[] { 3, 2, 1 }); - Assert.That(left.Union(right), Is.EquivalentTo(expected)); + Assert.True(left.Union(right).Equals(expected)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_sets_are_equal() { var left = new CustomSet(); var right = new CustomSet(); - Assert.That(left, Is.EquivalentTo(right)); + Assert.True(left.Equals(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_set_is_not_equal_to_non_empty_set() { var left = new CustomSet(); var right = new CustomSet(new[] { 1, 2, 3 }); - Assert.That(left, Is.Not.EquivalentTo(right)); + Assert.False(left.Equals(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Non_empty_set_is_not_equal_to_empty_set() { var left = new CustomSet(new[] { 1, 2, 3 }); var right = new CustomSet(); - Assert.That(left, Is.Not.EquivalentTo(right)); + Assert.False(left.Equals(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sets_with_the_same_elements_are_equal() { var left = new CustomSet(new[] { 1, 2 }); var right = new CustomSet(new[] { 2, 1 }); - Assert.That(left, Is.EquivalentTo(right)); + Assert.True(left.Equals(right)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sets_with_different_elements_are_not_equal() { var left = new CustomSet(new[] { 1, 2, 3 }); var right = new CustomSet(new[] { 1, 2, 4 }); - Assert.That(left, Is.Not.EquivalentTo(right)); + Assert.False(left.Equals(right)); } } \ No newline at end of file diff --git a/exercises/custom-set/Example.cs b/exercises/custom-set/Example.cs index 40e69f3aaf..2d06875d26 100644 --- a/exercises/custom-set/Example.cs +++ b/exercises/custom-set/Example.cs @@ -1,8 +1,9 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; using System.Linq; -public class CustomSet : IEnumerable +public class CustomSet : IEnumerable, IEquatable> { private readonly Dictionary items = new Dictionary(); @@ -69,4 +70,16 @@ IEnumerator IEnumerable.GetEnumerator() } private IEnumerable GetValuesFromKeys(IEnumerable keys) => keys.Select(key => items[key]); + + public override bool Equals(object obj) => Equals(obj as IEnumerable); + + public bool Equals(IEnumerable other) + { + return items.Keys.OrderBy(x => x).SequenceEqual(other.Select(o => o.GetHashCode()).OrderBy(x => x)); + } + + public int GetHashCode(IEnumerable obj) + { + throw new NotImplementedException(); + } } \ No newline at end of file diff --git a/exercises/diamond/DiamondTest.cs b/exercises/diamond/DiamondTest.cs index 04290dbd0a..9f6e7db62c 100644 --- a/exercises/diamond/DiamondTest.cs +++ b/exercises/diamond/DiamondTest.cs @@ -1,38 +1,44 @@ using System; +using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; public class DiamondTest { - private static readonly char[] Letters = GetLetterRange('A', 'Z'); + public static readonly char[] AllLetters = GetLetterRange('A', 'Z'); + public static readonly IEnumerable Letters = AllLetters.Select(letter => new[] { (object)letter }); private static char[] GetLetterRange(char min, char max) => Enumerable.Range(min, max - min + 1).Select(i => (char) i).ToArray(); private static string[] Rows(string x) => x.Split(new[] { '\n' }, StringSplitOptions.None); - private static string LeadingSpaces(string x) => x.Substring(0, x.IndexOfAny(Letters)); - private static string TrailingSpaces(string x) => x.Substring(x.LastIndexOfAny(Letters) + 1); + private static string LeadingSpaces(string x) => x.Substring(0, x.IndexOfAny(AllLetters)); + private static string TrailingSpaces(string x) => x.Substring(x.LastIndexOfAny(AllLetters) + 1); - [TestCaseSource(nameof(Letters))] + [Theory] + [MemberData(nameof(Letters))] public void First_row_contains_A(char letter) { var actual = Diamond.Make(letter); var rows = Rows(actual); var firstRowCharacters = rows.First().Trim(); - Assert.That(firstRowCharacters, Is.EqualTo("A")); + Assert.Equal("A", firstRowCharacters); } - [Ignore("Remove to run test")] - [TestCaseSource(nameof(Letters))] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(Letters))] public void All_rows_must_have_symmetric_contour(char letter) { var actual = Diamond.Make(letter); var rows = Rows(actual); - Assert.That(rows, Is.All.Matches(row => LeadingSpaces(row) == TrailingSpaces(row))); + Assert.All(rows, row => + { + Assert.Equal(LeadingSpaces(row), TrailingSpaces(row)); + }); } - [Ignore("Remove to run test")] - [TestCaseSource(nameof(Letters))] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(Letters))] public void Top_of_figure_has_letters_in_correct_order(char letter) { var actual = Diamond.Make(letter); @@ -40,11 +46,11 @@ public void Top_of_figure_has_letters_in_correct_order(char letter) var expected = GetLetterRange('A', letter); var firstNonSpaceLetters = rows.Take(expected.Length).Select(row => row.Trim()[0]); - Assert.That(expected, Is.EqualTo(firstNonSpaceLetters)); + Assert.Equal(firstNonSpaceLetters, expected); } - [Ignore("Remove to run test")] - [TestCaseSource(nameof(Letters))] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(Letters))] public void Figure_is_symmetric_around_the_horizontal_axis(char letter) { var actual = Diamond.Make(letter); @@ -53,11 +59,11 @@ public void Figure_is_symmetric_around_the_horizontal_axis(char letter) var top = rows.TakeWhile(row => !row.Contains(letter)); var bottom = rows.Reverse().TakeWhile(row => !row.Contains(letter)); - Assert.That(top, Is.EqualTo(bottom)); + Assert.Equal(bottom, top); } - [Ignore("Remove to run test")] - [TestCaseSource(nameof(Letters))] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(Letters))] public void Diamond_has_square_shape(char letter) { var actual = Diamond.Make(letter); @@ -65,27 +71,30 @@ public void Diamond_has_square_shape(char letter) var rows = Rows(actual); var expected = rows.Length; - Assert.That(rows, Is.All.Matches(row => row.Length == expected)); + Assert.All(rows, row => + { + Assert.Equal(expected, row.Length); + }); } - [Ignore("Remove to run test")] - [TestCaseSource(nameof(Letters))] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(Letters))] public void All_rows_except_top_and_bottom_have_two_identical_letters(char letter) { var actual = Diamond.Make(letter); var rows = Rows(actual).Where(row => !row.Contains('A')); - Assert.That(rows, Is.All.Matches(row => + Assert.All(rows, row => { var twoCharacters = row.Replace(" ", "").Length == 2; var identicalCharacters = row.Replace(" ", "").Distinct().Count() == 1; - return twoCharacters && identicalCharacters; - })); + Assert.True(twoCharacters && identicalCharacters, "Does not have two identical letters"); + }); } - [Ignore("Remove to run test")] - [TestCaseSource(nameof(Letters))] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(Letters))] public void Bottom_left_corner_spaces_are_triangle(char letter) { var actual = Diamond.Make(letter); @@ -96,6 +105,6 @@ public void Bottom_left_corner_spaces_are_triangle(char letter) var spaceCounts = cornerSpaces.Select(row => row.Length).ToList(); var expected = Enumerable.Range(0, spaceCounts.Count).Select(i => i).ToList(); - Assert.That(spaceCounts, Is.EqualTo(expected)); + Assert.Equal(expected, spaceCounts); } } \ No newline at end of file diff --git a/exercises/difference-of-squares/DifferenceOfSquaresTest.cs b/exercises/difference-of-squares/DifferenceOfSquaresTest.cs index 0d7e66655d..6a5e4fc0da 100644 --- a/exercises/difference-of-squares/DifferenceOfSquaresTest.cs +++ b/exercises/difference-of-squares/DifferenceOfSquaresTest.cs @@ -1,82 +1,71 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class DifferenceOfSquaresTests { - [Test] + [Fact] public void Test_square_of_sums_to_5() { - Assert.That(new Squares(5).SquareOfSums(), Is.EqualTo(225)); + Assert.Equal(225, new Squares(5).SquareOfSums()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_sum_of_squares_to_5() { - Assert.That(new Squares(5).SumOfSquares(), Is.EqualTo(55)); + Assert.Equal(55, new Squares(5).SumOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_difference_of_sums_to_5() { - Assert.That(new Squares(5).DifferenceOfSquares(), Is.EqualTo(170)); + Assert.Equal(170, new Squares(5).DifferenceOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_of_sums_to_10() { - Assert.That(new Squares(10).SquareOfSums(), Is.EqualTo(3025)); + Assert.Equal(3025, new Squares(10).SquareOfSums()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_sum_of_squares_to_10() { - Assert.That(new Squares(10).SumOfSquares(), Is.EqualTo(385)); + Assert.Equal(385, new Squares(10).SumOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_difference_of_sums_to_10() { - Assert.That(new Squares(10).DifferenceOfSquares(), Is.EqualTo(2640)); + Assert.Equal(2640, new Squares(10).DifferenceOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_of_sums_to_100() { - Assert.That(new Squares(100).SquareOfSums(), Is.EqualTo(25502500)); + Assert.Equal(25502500, new Squares(100).SquareOfSums()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_sum_of_squares_to_100() { - Assert.That(new Squares(100).SumOfSquares(), Is.EqualTo(338350)); + Assert.Equal(338350, new Squares(100).SumOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_difference_of_sums_to_100() { - Assert.That(new Squares(100).DifferenceOfSquares(), Is.EqualTo(25164150)); + Assert.Equal(25164150, new Squares(100).DifferenceOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_difference_of_sums_0() { - Assert.That(new Squares(0).DifferenceOfSquares(), Is.EqualTo(0)); + Assert.Equal(0, new Squares(0).DifferenceOfSquares()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_negative_numbers_throw_argument_out_of_range_exception() { - Assert.That(() => new Squares(-5), Throws.TypeOf()); + Assert.Throws(() => new Squares(-5)); } } diff --git a/exercises/diffie-hellman/DiffieHellmanTest.cs b/exercises/diffie-hellman/DiffieHellmanTest.cs index 5fbd6d5c48..dd66ac78eb 100644 --- a/exercises/diffie-hellman/DiffieHellmanTest.cs +++ b/exercises/diffie-hellman/DiffieHellmanTest.cs @@ -1,30 +1,31 @@ using System.Linq; using System.Numerics; -using NUnit.Framework; +using Xunit; public class DiffieHellmanTest { - [Test] + [Fact] public void Private_key_in_range() { var primeP = new BigInteger(23); var privateKeys = Enumerable.Range(0, 10).Select(_ => DiffieHellman.PrivateKey(primeP)).ToList(); - Assert.That(privateKeys, Is.All.InRange(new BigInteger(1), primeP - new BigInteger(1))); + Assert.All(privateKeys, privateKey => + { + Assert.InRange(privateKey, new BigInteger(1), primeP - new BigInteger(1)); + }); } // Note: due to the nature of randomness, there is always a chance that this test fails // Be sure to check the actual generated values - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Private_key_randomly_generated() { var primeP = new BigInteger(7919); var privateKeys = Enumerable.Range(0, 5).Select(_ => DiffieHellman.PrivateKey(primeP)).ToList(); - Assert.That(privateKeys.Count, Is.EqualTo(privateKeys.Distinct().Count())); + Assert.Equal(privateKeys.Distinct().Count(), privateKeys.Count); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Public_key_correctly_calculated() { var primeP = new BigInteger(23); @@ -32,11 +33,10 @@ public void Public_key_correctly_calculated() var privateKey = new BigInteger(6); var actual = DiffieHellman.PublicKey(primeP, primeG, privateKey); - Assert.That(actual, Is.EqualTo(new BigInteger(8))); + Assert.Equal(new BigInteger(8), actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Secret_key_correctly_calculated() { var primeP = new BigInteger(23); @@ -44,11 +44,10 @@ public void Secret_key_correctly_calculated() var privateKey = new BigInteger(6); var actual = DiffieHellman.Secret(primeP, publicKey, privateKey); - Assert.That(actual, Is.EqualTo(new BigInteger(2))); + Assert.Equal(new BigInteger(2), actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Secret_key_correctly_calculated_when_using_large_primes() { var primeP = BigInteger.Parse("120227323036150778550155526710966921740030662694578947298423549235265759593711587341037426347114541533006628856300552706996143592240453345642869233562886752930249953227657883929905072620233073626594386072962776144691433658814261874113232461749035425712805067202910389407991986070558964461330091797026762932543"); @@ -56,11 +55,10 @@ public void Secret_key_correctly_calculated_when_using_large_primes() var privateKey = BigInteger.Parse("2483479393625932939911081304356888505153797135447327501792696199190469015215177630758617902200417377685436170904594686456961202706692908603181062371925882"); var expected = BigInteger.Parse("70900735223964890815905879227737819348808518698920446491346508980461201746567735331455825644429877946556431095820785835497384849778344216981228226252639932672153547963980483673419756271345828771971984887453014488572245819864454136618980914729839523581263886740821363010486083940557620831348661126601106717071"); var actual = DiffieHellman.Secret(primeP, publicKey, privateKey); - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_exchange() { var primeP = new BigInteger(23); @@ -75,6 +73,6 @@ public void Test_exchange() var secretA = DiffieHellman.Secret(primeP, publicKeyB, privateKeyA); var secretB = DiffieHellman.Secret(primeP, publicKeyA, privateKeyB); - Assert.That(secretA, Is.EqualTo(secretB)); + Assert.Equal(secretB, secretA); } } diff --git a/exercises/dominoes/DominoesTest.cs b/exercises/dominoes/DominoesTest.cs index 9fe0e86592..9e6307e71a 100644 --- a/exercises/dominoes/DominoesTest.cs +++ b/exercises/dominoes/DominoesTest.cs @@ -1,100 +1,89 @@ using System; -using NUnit.Framework; +using Xunit; public class DominoesTest { - [Test] + [Fact] public void Empty_input_equals_empty_output() { var actual = new Tuple[0]; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Singleton_input_equals_singleton_output() { var actual = new[] { Tuple.Create(1, 1) }; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Singleton_that_cant_be_chained() { var actual = new[] { Tuple.Create(1, 2) }; - Assert.That(Dominoes.CanChain(actual), Is.False); + Assert.False(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Three_elements() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(3, 1), Tuple.Create(2, 3) }; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Can_reverse_dominoes() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(1, 3), Tuple.Create(2, 3) }; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Cant_be_chained() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(4, 1), Tuple.Create(2, 3) }; - Assert.That(Dominoes.CanChain(actual), Is.False); + Assert.False(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Disconnected_simple() { var actual = new[] { Tuple.Create(1, 1), Tuple.Create(2, 2) }; - Assert.That(Dominoes.CanChain(actual), Is.False); + Assert.False(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Disconnected_double_loop() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(2, 1), Tuple.Create(3, 4), Tuple.Create(4, 3) }; - Assert.That(Dominoes.CanChain(actual), Is.False); + Assert.False(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Disconnected_single_isolated() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(2, 3), Tuple.Create(3, 1), Tuple.Create(4, 4) }; - Assert.That(Dominoes.CanChain(actual), Is.False); + Assert.False(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Need_backtrack() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(2, 3), Tuple.Create(3, 1), Tuple.Create(2, 4), Tuple.Create(2, 4) }; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } - - [Ignore("Remove to run test")] - [Test] + + [Fact(Skip = "Remove to run test")] public void Separate_loops() { var actual = new[] { Tuple.Create(1, 2), Tuple.Create(2, 3), Tuple.Create(3, 1), Tuple.Create(1, 1), Tuple.Create(2, 2), Tuple.Create(3, 3) }; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Ten_elements() { var actual = new[] @@ -102,6 +91,6 @@ public void Ten_elements() Tuple.Create(1, 2), Tuple.Create(5, 3), Tuple.Create(3, 1), Tuple.Create(1, 2), Tuple.Create(2, 4), Tuple.Create(1, 6), Tuple.Create(2, 3), Tuple.Create(3, 4), Tuple.Create(5, 6) }; - Assert.That(Dominoes.CanChain(actual), Is.True); + Assert.True(Dominoes.CanChain(actual)); } } \ No newline at end of file diff --git a/exercises/dot-dsl/DotDslTest.cs b/exercises/dot-dsl/DotDslTest.cs index 615fb1f84f..9e0c45b6b7 100644 --- a/exercises/dot-dsl/DotDslTest.cs +++ b/exercises/dot-dsl/DotDslTest.cs @@ -1,19 +1,21 @@ -using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; public class DotDslTest { - [Test] + [Fact] public void Empty_graph() { var g = new Graph(); - Assert.That(g.Nodes, Is.Empty); - Assert.That(g.Edges, Is.Empty); - Assert.That(g.Attrs, Is.Empty); + Assert.Empty(g.Nodes); + Assert.Empty(g.Edges); + Assert.Empty(g.Attrs); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Graph_with_one_node() { var g = new Graph @@ -21,13 +23,12 @@ public void Graph_with_one_node() new Node("a") }; - Assert.That(g.Nodes, Is.EquivalentTo(new[] { new Node("a") })); - Assert.That(g.Edges, Is.Empty); - Assert.That(g.Attrs, Is.Empty); + Assert.Equal(new[] { new Node("a") }, g.Nodes); + Assert.Empty(g.Edges); + Assert.Empty(g.Attrs); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Graph_with_one_node_with_keywords() { var g = new Graph @@ -35,13 +36,12 @@ public void Graph_with_one_node_with_keywords() new Node("a") { { "color", "green" } } }; - Assert.That(g.Nodes, Is.EquivalentTo(new[] { new Node("a") { { "color", "green" } } })); - Assert.That(g.Edges, Is.Empty); - Assert.That(g.Attrs, Is.Empty); + Assert.Equal(new[] { new Node("a") { { "color", "green" } } }, g.Nodes); + Assert.Empty(g.Edges); + Assert.Empty(g.Attrs); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Graph_with_one_edge() { var g = new Graph @@ -49,13 +49,12 @@ public void Graph_with_one_edge() new Edge("a", "b") }; - Assert.That(g.Nodes, Is.Empty); - Assert.That(g.Edges, Is.EquivalentTo(new[] { new Edge("a", "b") })); - Assert.That(g.Attrs, Is.Empty); + Assert.Empty(g.Nodes); + Assert.Equal(new[] { new Edge("a", "b") }, g.Edges); + Assert.Empty(g.Attrs); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Graph_with_one_attribute() { var g = new Graph @@ -63,13 +62,12 @@ public void Graph_with_one_attribute() { "foo", "1" } }; - Assert.That(g.Nodes, Is.Empty); - Assert.That(g.Edges, Is.Empty); - Assert.That(g.Attrs, Is.EquivalentTo(new[] { new Attr("foo", "1") })); + Assert.Empty(g.Nodes); + Assert.Empty(g.Edges); + Assert.Equal(new[] { new Attr("foo", "1") }, g.Attrs); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Graph_with_attributes() { var g = new Graph @@ -84,8 +82,20 @@ public void Graph_with_attributes() { "bar", "true" } }; - Assert.That(g.Nodes, Is.EquivalentTo(new[] { new Node("a") { { "color", "green" } }, new Node("b") { { "label", "Beta!" } }, new Node("c") })); - Assert.That(g.Edges, Is.EquivalentTo(new[] { new Edge("a", "b") { { "color", "blue" } }, new Edge("b", "c") })); - Assert.That(g.Attrs, Is.EquivalentTo(new[] { new Attr("bar", "true"), new Attr("foo", "1"), new Attr("title", "Testing Attrs") })); + Assert.Equal(new[] { new Node("a") { { "color", "green" } }, new Node("b") { { "label", "Beta!" } }, new Node("c") }, g.Nodes, EnumerableEqualityComparer.Instance); + Assert.Equal(new[] { new Edge("a", "b") { { "color", "blue" } }, new Edge("b", "c") }, g.Edges, EnumerableEqualityComparer.Instance); + Assert.Equal(new[] { new Attr("bar", "true"), new Attr("foo", "1"), new Attr("title", "Testing Attrs") }, g.Attrs, EnumerableEqualityComparer.Instance); + } + + private class EnumerableEqualityComparer : IEqualityComparer> + { + public static readonly EnumerableEqualityComparer Instance = new EnumerableEqualityComparer(); + + public bool Equals(IEnumerable x, IEnumerable y) => new HashSet(x).SetEquals(y); + + public int GetHashCode(IEnumerable obj) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/exercises/error-handling/ErrorHandlingTest.cs b/exercises/error-handling/ErrorHandlingTest.cs index 545560bf0c..ff8bd317d9 100644 --- a/exercises/error-handling/ErrorHandlingTest.cs +++ b/exercises/error-handling/ErrorHandlingTest.cs @@ -1,43 +1,40 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class ErrorHandlingTest { // Read more about exception handling here: // https://msdn.microsoft.com/en-us/library/ms173162.aspx?f=255&MSPPError=-2147217396 - [Test] + [Fact] public void ThrowException() { - Assert.Throws(ErrorHandling.HandleErrorByThrowingException); + Assert.Throws(() => ErrorHandling.HandleErrorByThrowingException()); } // Read more about nullable types here: // https://msdn.microsoft.com/en-us/library/1t3y8s4s.aspx?f=255&MSPPError=-2147217396 - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void ReturnNullableType() { var successfulResult = ErrorHandling.HandleErrorByReturningNullableType("1"); - Assert.That(successfulResult, Is.EqualTo(1)); + Assert.Equal(1, successfulResult); var failureResult = ErrorHandling.HandleErrorByReturningNullableType("a"); - Assert.That(failureResult, Is.EqualTo(null)); + Assert.Equal(null, failureResult); } // Read more about out parameters here: // https://msdn.microsoft.com/en-us/library/t3c3bfhx.aspx?f=255&MSPPError=-2147217396 - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void ReturnWithOutParameter() { int result; var successfulResult = ErrorHandling.HandleErrorWithOutParam("1", out result); - Assert.That(successfulResult, Is.EqualTo(true)); - Assert.That(result, Is.EqualTo(1)); + Assert.Equal(true, successfulResult); + Assert.Equal(1, result); var failureResult = ErrorHandling.HandleErrorWithOutParam("a", out result); - Assert.That(failureResult, Is.EqualTo(false)); + Assert.Equal(false, failureResult); // The value of result is meaningless here (it could be anything) so it shouldn't be used and it's not validated } @@ -53,13 +50,12 @@ public void Dispose() // Read more about IDisposable here: // https://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void DisposableObjectsAreDisposedWhenThrowingAnException() { var disposableResource = new DisposableResource(); Assert.Throws(() => ErrorHandling.DisposableResourcesAreDisposedWhenExceptionIsThrown(disposableResource)); - Assert.That(disposableResource.IsDisposed, Is.EqualTo(true)); + Assert.Equal(true, disposableResource.IsDisposed); } } diff --git a/exercises/etl/ETLTest.cs b/exercises/etl/ETLTest.cs index 4426fe6eff..171736878a 100644 --- a/exercises/etl/ETLTest.cs +++ b/exercises/etl/ETLTest.cs @@ -1,37 +1,33 @@ using System.Collections.Generic; -using NUnit.Framework; +using Xunit; -[TestFixture] public class ETLTest { - [Test] + [Fact] public void Transforms_one_value() { var old = new Dictionary> { { 1, new List { "A" } } }; var expected = new Dictionary { { "a", 1 } }; - Assert.That(ETL.Transform(old), Is.EqualTo(expected)); + Assert.Equal(expected, ETL.Transform(old)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Transforms_multiple_values() { var old = new Dictionary> { { 1, new List { "A", "E", "I", "O", "U" } } }; var expected = new Dictionary { { "a", 1 }, { "e", 1 }, { "i", 1 }, { "o", 1 }, { "u", 1 } }; - Assert.That(ETL.Transform(old), Is.EqualTo(expected)); + Assert.Equal(expected, ETL.Transform(old)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Transforms_multiple_keys() { var old = new Dictionary> { { 1, new List { "A", "E" } }, { 2, new List { "D", "G" } } }; var expected = new Dictionary { { "a", 1 }, { "e", 1 }, { "d", 2 }, { "g", 2 } }; - Assert.That(ETL.Transform(old), Is.EqualTo(expected)); + Assert.Equal(expected, ETL.Transform(old)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Transforms_a_full_dataset() { var old = new Dictionary> @@ -50,6 +46,6 @@ public void Transforms_a_full_dataset() { "j", 8 }, { "k", 5 }, { "l", 1 }, { "m", 3 }, { "n", 1 }, { "o", 1 }, { "p", 3 }, { "q", 10 }, { "r", 1 }, { "s", 1 }, { "t", 1 }, { "u", 1 }, { "v", 4 }, { "w", 4 }, { "x", 8 }, { "y", 4 }, { "z", 10 } }; - Assert.That(ETL.Transform(old), Is.EqualTo(expected)); + Assert.Equal(expected, ETL.Transform(old)); } } \ No newline at end of file diff --git a/exercises/exercises.csproj b/exercises/exercises.csproj index 2432130d5d..4a87d0915b 100644 --- a/exercises/exercises.csproj +++ b/exercises/exercises.csproj @@ -43,59 +43,28 @@ + + + - - - - ..\packages\NUnit\lib\net20\NUnit.System.Linq.dll - True - True - - - ..\packages\NUnit\lib\net20\nunit.framework.dll - True - True - - - - - - - ..\packages\NUnit\lib\net35\nunit.framework.dll - True - True - - - - - - - ..\packages\NUnit\lib\net40\nunit.framework.dll - True - True - - + + + <__paket__xunit_core_props>portable-net45+win8+wp8+wpa81\xunit.core + - - - - ..\packages\NUnit\lib\net45\nunit.framework.dll - True - True - - + + + <__paket__xunit_core_props>win81\xunit.core + - - - - ..\packages\NUnit\lib\portable-net45+win8+wp8+wpa81+Xamarin.Mac+MonoAndroid10+MonoTouch10+Xamarin.iOS10\nunit.framework.dll - True - True - - + + + <__paket__xunit_core_props>wpa81\xunit.core + + @@ -154,17 +123,6 @@ - - - - - ..\packages\System.Diagnostics.Debug\ref\netstandard1.3\System.Diagnostics.Debug.dll - False - True - - - - @@ -188,50 +146,46 @@ - - ..\packages\System.IO\ref\netstandard1.5\System.IO.dll - False + + ..\packages\System.Linq\lib\netstandard1.6\System.Linq.dll + True True - + - - ..\packages\System.Linq\ref\netstandard1.0\System.Linq.dll + + ..\packages\System.Runtime\ref\netstandard1.0\System.Runtime.dll False True - + - - ..\packages\System.Linq\ref\netstandard1.6\System.Linq.dll + + ..\packages\System.Runtime\ref\netstandard1.2\System.Runtime.dll False True - - - + - - ..\packages\System.Reflection\ref\netstandard1.5\System.Reflection.dll + + ..\packages\System.Runtime\ref\netstandard1.3\System.Runtime.dll False True - - - + - - ..\packages\System.Reflection.Primitives\ref\netstandard1.0\System.Reflection.Primitives.dll + + ..\packages\System.Runtime\ref\netstandard1.5\System.Runtime.dll False True @@ -239,122 +193,156 @@ - + - - ..\packages\System.Resources.ResourceManager\ref\netstandard1.0\System.Resources.ResourceManager.dll + + ..\packages\System.Text.RegularExpressions\ref\netstandard1.0\System.Text.RegularExpressions.dll False True - - - + - - ..\packages\System.Runtime\ref\netstandard1.0\System.Runtime.dll + + ..\packages\System.Text.RegularExpressions\ref\netstandard1.3\System.Text.RegularExpressions.dll False True - + - - ..\packages\System.Runtime\ref\netstandard1.2\System.Runtime.dll - False + + ..\packages\System.Text.RegularExpressions\lib\netstandard1.6\System.Text.RegularExpressions.dll + True True - + + + - - ..\packages\System.Runtime\ref\netstandard1.3\System.Runtime.dll - False + + ..\packages\System.Threading\lib\netstandard1.3\System.Threading.dll + True True - + + + - - ..\packages\System.Runtime\ref\netstandard1.5\System.Runtime.dll - False + + ..\packages\xunit.abstractions\lib\net35\xunit.abstractions.dll + True + True + + + + + + + ..\packages\xunit.abstractions\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.abstractions.dll + True True - + - - ..\packages\System.Runtime.Extensions\ref\netstandard1.5\System.Runtime.Extensions.dll - False + + ..\packages\xunit.assert\lib\portable-net45+win8+wp8+wpa81\xunit.assert.dll + True True - + - - ..\packages\System.Text.Encoding\ref\netstandard1.3\System.Text.Encoding.dll - False + + ..\packages\xunit.extensibility.core\lib\portable-net45+win8+wp8+wpa81\xunit.core.dll + True True - + - - ..\packages\System.Text.RegularExpressions\ref\netstandard1.0\System.Text.RegularExpressions.dll - False + + ..\packages\xunit.extensibility.execution\lib\monoandroid\xunit.execution.dotnet.dll + True True - + - - ..\packages\System.Text.RegularExpressions\ref\netstandard1.3\System.Text.RegularExpressions.dll - False + + ..\packages\xunit.extensibility.execution\lib\monotouch\xunit.execution.dotnet.dll + True True - + - - ..\packages\System.Text.RegularExpressions\ref\netstandard1.6\System.Text.RegularExpressions.dll - False + + ..\packages\xunit.extensibility.execution\lib\net45\xunit.execution.desktop.dll + True True - - - + - - ..\packages\System.Threading\ref\netstandard1.3\System.Threading.dll - False + + ..\packages\xunit.extensibility.execution\lib\portable-net45+win8+wp8+wpa81\xunit.execution.dotnet.dll + True True - - - + - - ..\packages\System.Threading.Tasks\ref\netstandard1.3\System.Threading.Tasks.dll - False + + ..\packages\xunit.extensibility.execution\lib\win8\xunit.execution.dotnet.dll + True + True + + + + + + + ..\packages\xunit.extensibility.execution\lib\wp8\xunit.execution.dotnet.dll + True + True + + + + + + + ..\packages\xunit.extensibility.execution\lib\wpa81\xunit.execution.dotnet.dll + True + True + + + + + + + ..\packages\xunit.extensibility.execution\lib\xamarinios\xunit.execution.dotnet.dll + True True diff --git a/exercises/exercises.sln b/exercises/exercises.sln new file mode 100644 index 0000000000..dee915d11f --- /dev/null +++ b/exercises/exercises.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "exercises", "exercises.csproj", "{FEF69435-D885-45DD-A446-04FD3BD3F593}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FEF69435-D885-45DD-A446-04FD3BD3F593}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FEF69435-D885-45DD-A446-04FD3BD3F593}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FEF69435-D885-45DD-A446-04FD3BD3F593}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FEF69435-D885-45DD-A446-04FD3BD3F593}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/exercises/flatten-array/FlattenArrayTest.cs b/exercises/flatten-array/FlattenArrayTest.cs index d609e3add5..e9d1e93e1c 100644 --- a/exercises/flatten-array/FlattenArrayTest.cs +++ b/exercises/flatten-array/FlattenArrayTest.cs @@ -1,25 +1,25 @@ -using System.Collections.Generic; -using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; public class FlattenArrayTest { - [Test] + [Fact] public void Flattens_A_Nested_List() { var nestedList = new List { new List() }; - Assert.That(Flattener.Flatten(nestedList), Is.Empty); + Assert.Empty(Flattener.Flatten(nestedList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Flattens_2_Level_Nested_List() { var nestedList = new List { 1, new List { 2, 3, 4 }, 5 }; - Assert.That(Flattener.Flatten(nestedList), Is.EquivalentTo(new List { 1, 2, 3, 4, 5 })); + Assert.Equal(new List { 1, 2, 3, 4, 5 }, Flattener.Flatten(nestedList).Cast()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Flattens_3_Level_Nested_List() { var nestedList = new List @@ -29,11 +29,10 @@ public void Flattens_3_Level_Nested_List() 5, new List { 6, new List { 7, 8 } } }; - Assert.That(Flattener.Flatten(nestedList), Is.EquivalentTo(new List { 1, 2, 3, 4, 5, 6, 7, 8 })); + Assert.Equal(new List { 1, 2, 3, 4, 5, 6, 7, 8 }, Flattener.Flatten(nestedList).Cast()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Flattens_5_Level_Nested_List() { var nestedList = new List @@ -50,11 +49,10 @@ public void Flattens_5_Level_Nested_List() -2 } }; - Assert.That(Flattener.Flatten(nestedList), Is.EquivalentTo(new List { 0, 2, 2, 3, 8, 100, 4, 50, -2 })); + Assert.Equal(new List { 0, 2, 2, 3, 8, 100, 4, 50, -2 }, Flattener.Flatten(nestedList).Cast()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Flattens_6_Level_Nested_List() { var nestedList = new List @@ -70,11 +68,10 @@ public void Flattens_6_Level_Nested_List() }, 8 }; - Assert.That(Flattener.Flatten(nestedList), Is.EquivalentTo(new List { 1, 2, 3, 4, 5, 6, 7, 8 })); + Assert.Equal(new List { 1, 2, 3, 4, 5, 6, 7, 8 }, Flattener.Flatten(nestedList).Cast()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Flattens_6_Level_Nested_List_With_Nulls() { var nestedList = new List @@ -93,11 +90,10 @@ public void Flattens_6_Level_Nested_List_With_Nulls() 8, null }; - Assert.That(Flattener.Flatten(nestedList), Is.EquivalentTo(new List { 1, 2, 3, 4, 5, 6, 7, 8 })); + Assert.Equal(new List { 1, 2, 3, 4, 5, 6, 7, 8 }, Flattener.Flatten(nestedList).Cast()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void All_Null_Nested_List_Returns_Empty_List() { var nestedList = new List @@ -111,6 +107,6 @@ public void All_Null_Nested_List_Returns_Empty_List() }, null }; - Assert.That(Flattener.Flatten(nestedList), Is.Empty); + Assert.Empty(Flattener.Flatten(nestedList)); } } \ No newline at end of file diff --git a/exercises/food-chain/FoodChainTest.cs b/exercises/food-chain/FoodChainTest.cs index 3493c0b079..f625e58cf8 100644 --- a/exercises/food-chain/FoodChainTest.cs +++ b/exercises/food-chain/FoodChainTest.cs @@ -1,18 +1,17 @@ -using NUnit.Framework; +using Xunit; public class FoodChainTest { - [Test] + [Fact] public void Verse_one() { const string expected = "I know an old lady who swallowed a fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die."; - Assert.That(FoodChain.Verse(1), Is.EqualTo(expected)); + Assert.Equal(expected, FoodChain.Verse(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Verse_two() { const string expected = "I know an old lady who swallowed a spider.\n" + @@ -20,11 +19,10 @@ public void Verse_two() "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die."; - Assert.That(FoodChain.Verse(2), Is.EqualTo(expected)); + Assert.Equal(expected, FoodChain.Verse(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Verse_four() { const string expected = "I know an old lady who swallowed a cat.\n" + @@ -34,21 +32,19 @@ public void Verse_four() "She swallowed the spider to catch the fly.\n" + "I don't know why she swallowed the fly. Perhaps she'll die."; - Assert.That(FoodChain.Verse(4), Is.EqualTo(expected)); + Assert.Equal(expected, FoodChain.Verse(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Verse_eight() { const string expected = "I know an old lady who swallowed a horse.\n" + "She's dead, of course!"; - Assert.That(FoodChain.Verse(8), Is.EqualTo(expected)); + Assert.Equal(expected, FoodChain.Verse(8)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Complete_song() { const string expected = "I know an old lady who swallowed a fly.\n" + @@ -102,6 +98,6 @@ public void Complete_song() "I know an old lady who swallowed a horse.\n" + "She's dead, of course!"; - Assert.That(FoodChain.Song(), Is.EqualTo(expected)); + Assert.Equal(expected, FoodChain.Song()); } } \ No newline at end of file diff --git a/exercises/forth/ForthTest.cs b/exercises/forth/ForthTest.cs index fb64ad1166..88ec2e67a7 100644 --- a/exercises/forth/ForthTest.cs +++ b/exercises/forth/ForthTest.cs @@ -1,134 +1,120 @@ -using NUnit.Framework; +using Xunit; public class ForthTest { - [Test] + [Fact] public void No_input() { - Assert.That(Forth.Eval(""), Is.EqualTo("")); + Assert.Equal("", Forth.Eval("")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Numbers_just_get_pushed_onto_the_stack() { - Assert.That(Forth.Eval("1 2 3 4 5"), Is.EqualTo("1 2 3 4 5")); + Assert.Equal("1 2 3 4 5", Forth.Eval("1 2 3 4 5")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Non_word_characters_are_separators() { - Assert.That(Forth.Eval("1\v2\t3\n4\r5 6\t7"), Is.EqualTo("1 2 3 4 5 6 7")); + Assert.Equal("1 2 3 4 5 6 7", Forth.Eval("1\v2\t3\n4\r5 6\t7")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Basic_arithmetic() { - Assert.That(Forth.Eval("1 2 + 4 -"), Is.EqualTo("-1")); - Assert.That(Forth.Eval("2 4 * 3 /"), Is.EqualTo("2")); + Assert.Equal("-1", Forth.Eval("1 2 + 4 -")); + Assert.Equal("2", Forth.Eval("2 4 * 3 /")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Division_by_zero() { var exception = Assert.Throws(() => Forth.Eval("4 2 2 - /")); - Assert.That(exception.Error, Is.EqualTo(ForthError.DivisionByZero)); + Assert.Equal(ForthError.DivisionByZero, exception.Error); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void dup() { - Assert.That(Forth.Eval("1 DUP"), Is.EqualTo("1 1")); - Assert.That(Forth.Eval("1 2 Dup"), Is.EqualTo("1 2 2")); + Assert.Equal("1 1", Forth.Eval("1 DUP")); + Assert.Equal("1 2 2", Forth.Eval("1 2 Dup")); var exception = Assert.Throws(() => Forth.Eval("dup")); - Assert.That(exception.Error, Is.EqualTo(ForthError.StackUnderflow)); + Assert.Equal(ForthError.StackUnderflow, exception.Error); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void drop() { - Assert.That(Forth.Eval("1 drop"), Is.EqualTo("")); - Assert.That(Forth.Eval("1 2 drop"), Is.EqualTo("1")); + Assert.Equal("", Forth.Eval("1 drop")); + Assert.Equal("1", Forth.Eval("1 2 drop")); var exception = Assert.Throws(() => Forth.Eval("drop")); - Assert.That(exception.Error, Is.EqualTo(ForthError.StackUnderflow)); + Assert.Equal(ForthError.StackUnderflow, exception.Error); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void swap() { - Assert.That(Forth.Eval("1 2 swap"), Is.EqualTo("2 1")); - Assert.That(Forth.Eval("1 2 3 swap"), Is.EqualTo("1 3 2")); + Assert.Equal("2 1", Forth.Eval("1 2 swap")); + Assert.Equal("1 3 2", Forth.Eval("1 2 3 swap")); var exception1 = Assert.Throws(() => Forth.Eval("1 swap")); - Assert.That(exception1.Error, Is.EqualTo(ForthError.StackUnderflow)); + Assert.Equal(ForthError.StackUnderflow, exception1.Error); var exception2 = Assert.Throws(() => Forth.Eval("swap")); - Assert.That(exception2.Error, Is.EqualTo(ForthError.StackUnderflow)); + Assert.Equal(ForthError.StackUnderflow, exception2.Error); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void over() { - Assert.That(Forth.Eval("1 2 over"), Is.EqualTo("1 2 1")); - Assert.That(Forth.Eval("1 2 3 over"), Is.EqualTo("1 2 3 2")); + Assert.Equal("1 2 1", Forth.Eval("1 2 over")); + Assert.Equal("1 2 3 2", Forth.Eval("1 2 3 over")); var exception1 = Assert.Throws(() => Forth.Eval("1 over")); - Assert.That(exception1.Error, Is.EqualTo(ForthError.StackUnderflow)); + Assert.Equal(ForthError.StackUnderflow, exception1.Error); var exception2 = Assert.Throws(() => Forth.Eval("over")); - Assert.That(exception2.Error, Is.EqualTo(ForthError.StackUnderflow)); + Assert.Equal(ForthError.StackUnderflow, exception2.Error); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Defining_a_new_word() { - Assert.That(Forth.Eval(": dup-twice dup dup ; 1 dup-twice"), Is.EqualTo("1 1 1")); + Assert.Equal("1 1 1", Forth.Eval(": dup-twice dup dup ; 1 dup-twice")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Redefining_an_existing_word() { - Assert.That(Forth.Eval(": foo dup ; : foo dup dup ; 1 foo"), Is.EqualTo("1 1 1")); + Assert.Equal("1 1 1", Forth.Eval(": foo dup ; : foo dup dup ; 1 foo")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Redefining_an_existing_built_in_word() { - Assert.That(Forth.Eval(": swap dup ; 1 swap"), Is.EqualTo("1 1")); + Assert.Equal("1 1", Forth.Eval(": swap dup ; 1 swap")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Defining_words_with_odd_characters() { - Assert.That(Forth.Eval(": € 220371 ; €"), Is.EqualTo("220371")); + Assert.Equal("220371", Forth.Eval(": € 220371 ; €")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Defining_a_number() { var exception = Assert.Throws(() => Forth.Eval(": 1 2 ;")); - Assert.That(exception.Error, Is.EqualTo(ForthError.InvalidWord)); + Assert.Equal(ForthError.InvalidWord, exception.Error); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Calling_a_non_existing_word() { var exception = Assert.Throws(() => Forth.Eval("1 foo")); - Assert.That(exception.Error, Is.EqualTo(ForthError.UnknownWord)); + Assert.Equal(ForthError.UnknownWord, exception.Error); } } diff --git a/exercises/gigasecond/GigasecondTest.cs b/exercises/gigasecond/GigasecondTest.cs index e8ab02053d..4f7322916d 100644 --- a/exercises/gigasecond/GigasecondTest.cs +++ b/exercises/gigasecond/GigasecondTest.cs @@ -1,29 +1,26 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class GigasecondTest { - [Test] + [Fact] public void First_date() { var date = Gigasecond.Date(new DateTime(2011, 4, 25, 0, 0, 0, DateTimeKind.Utc)); - Assert.That(date, Is.EqualTo(new DateTime(2043, 1, 1, 1, 46, 40, DateTimeKind.Utc))); + Assert.Equal(new DateTime(2043, 1, 1, 1, 46, 40, DateTimeKind.Utc), date); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Another_date() { var date = Gigasecond.Date(new DateTime(1977, 6, 13, 0, 0, 0, DateTimeKind.Utc)); - Assert.That(date, Is.EqualTo(new DateTime(2009, 2, 19, 1, 46, 40, DateTimeKind.Utc))); + Assert.Equal(new DateTime(2009, 2, 19, 1, 46, 40, DateTimeKind.Utc), date); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Yet_another_date() { var date = Gigasecond.Date(new DateTime(1959, 7, 19, 0, 0, 0, DateTimeKind.Utc)); - Assert.That(date, Is.EqualTo(new DateTime(1991, 3, 27, 1, 46, 40, DateTimeKind.Utc))); + Assert.Equal(new DateTime(1991, 3, 27, 1, 46, 40, DateTimeKind.Utc), date); } } \ No newline at end of file diff --git a/exercises/go-counting/GoCountingTest.cs b/exercises/go-counting/GoCountingTest.cs index b16a3b9384..1ce6ccc826 100644 --- a/exercises/go-counting/GoCountingTest.cs +++ b/exercises/go-counting/GoCountingTest.cs @@ -1,7 +1,8 @@ -using NUnit.Framework; +using Xunit; using System; using System.Collections.Generic; using System.Drawing; +using System.Linq; public class GoCountingTest { @@ -29,61 +30,58 @@ public class GoCountingTest " B B " }); - [Test] + [Fact] public void FiveByFiveTerritoryForBlack() { var board = new GoCounting(boardFiveByFive); var result = board.TerritoryFor(new Point(0, 1)); - Assert.That(result.Item1, Is.EqualTo(GoCounting.Player.Black)); - Assert.That(result.Item2, Is.EquivalentTo(new[] { new Point(0, 0), new Point(0, 1), new Point(1, 0) })); + var expected = new HashSet { new Point(0, 0), new Point(0, 1), new Point(1, 0) }; + Assert.Equal(GoCounting.Player.Black, result.Item1); + Assert.True(expected.SetEquals(result.Item2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FiveByFiveTerritoryForWhite() { var board = new GoCounting(boardFiveByFive); var result = board.TerritoryFor(new Point(2, 3)); - Assert.That(result.Item1, Is.EqualTo(GoCounting.Player.White)); - Assert.That(result.Item2, Is.EquivalentTo(new[] { new Point(2, 3) })); + var expected = new HashSet { new Point(2, 3) }; + Assert.Equal(GoCounting.Player.White, result.Item1); + Assert.True(expected.SetEquals(result.Item2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FiveByFiveOpenTerritory() { var board = new GoCounting(boardFiveByFive); var result = board.TerritoryFor(new Point(1, 4)); - Assert.That(result.Item1, Is.EqualTo(GoCounting.Player.None)); - Assert.That(result.Item2, Is.EquivalentTo(new[] { new Point(0, 3), new Point(0, 4), new Point(1, 4) })); + var expected = new HashSet { new Point(0, 3), new Point(0, 4), new Point(1, 4) }; + Assert.Equal(GoCounting.Player.None, result.Item1); + Assert.True(expected.SetEquals(result.Item2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FiveByFiveNonTerritoryStone() { var board = new GoCounting(boardFiveByFive); - Assert.That(board.TerritoryFor(new Point(1, 1)), Is.Null); + Assert.Null(board.TerritoryFor(new Point(1, 1))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FiveByFiveNonTerritoryDueToTooLowCoordinate() { var board = new GoCounting(boardFiveByFive); - Assert.That(board.TerritoryFor(new Point(-1, 1)), Is.Null); + Assert.Null(board.TerritoryFor(new Point(-1, 1))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FiveByFiveNonTerritoryDueToTooHighCoordinate() { var board = new GoCounting(boardFiveByFive); - Assert.That(board.TerritoryFor(new Point(1, 5)), Is.Null); + Assert.Null(board.TerritoryFor(new Point(1, 5))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void MinimalBoardWithNoTerritories() { var input = "B"; @@ -91,37 +89,52 @@ public void MinimalBoardWithNoTerritories() var expected = new Dictionary>(); - Assert.That(board.Territories(), Is.EquivalentTo(expected)); + Assert.Equal(expected, board.Territories()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void OneTerritoryCoveringTheWholeBoard() { var input = " "; var board = new GoCounting(input); + var actual = board.Territories(); var expected = new Dictionary> { [GoCounting.Player.None] = new[] { new Point(0, 0) } }; - - Assert.That(board.Territories(), Is.EquivalentTo(expected)); + + Assert.Equal(expected.Keys, actual.Keys); + Assert.Equal(expected[GoCounting.Player.None], actual[GoCounting.Player.None]); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void TwoTerritoriesOnRectangularBoard() { var input = string.Join("\n", new[] { " BW ", " BW " }); var board = new GoCounting(input); + var actual = board.Territories(); var expected = new Dictionary> { [GoCounting.Player.Black] = new[] { new Point(0, 0), new Point(0, 1) }, [GoCounting.Player.White] = new[] { new Point(3, 0), new Point(3, 1) } }; + + Assert.Equal(expected.Keys, actual.Keys); + Assert.Equal(expected[GoCounting.Player.Black], actual[GoCounting.Player.Black]); + Assert.Equal(expected[GoCounting.Player.White], actual[GoCounting.Player.White]); + } + + private class EnumerableEqualityComparer : IEqualityComparer> + { + public static readonly EnumerableEqualityComparer Instance = new EnumerableEqualityComparer(); + + public bool Equals(IEnumerable x, IEnumerable y) => x.SequenceEqual(y); - Assert.That(board.Territories(), Is.EquivalentTo(expected)); + public int GetHashCode(IEnumerable obj) + { + throw new NotImplementedException(); + } } } diff --git a/exercises/grade-school/Example.cs b/exercises/grade-school/Example.cs index b556d33043..165a62e452 100644 --- a/exercises/grade-school/Example.cs +++ b/exercises/grade-school/Example.cs @@ -1,28 +1,26 @@ using System.Collections.Generic; +using System.Linq; public class School { - public IDictionary> Roster { get; private set; } - - public School() - { - Roster = new Dictionary>(); - } - + private readonly Dictionary> roster = new Dictionary>(); + public void Add(string student, int grade) { - if (Roster.ContainsKey(grade)) - Roster[grade].Add(student); + if (roster.ContainsKey(grade)) + roster[grade].Add(student); else - Roster.Add(grade, new SortedList { student }); + roster.Add(grade, new SortedList { student }); } - public IList Grade(int grade) + public IEnumerable Roster(int grade) => roster[grade]; + + public IEnumerable Grade(int grade) { IList students; - if (Roster.TryGetValue(grade, out students)) - return students; - return new List(0); + if (roster.TryGetValue(grade, out students)) + return students.AsEnumerable(); + return Enumerable.Empty(); } } diff --git a/exercises/grade-school/GradeSchoolTest.cs b/exercises/grade-school/GradeSchoolTest.cs index e38e09ac48..1391d164d1 100644 --- a/exercises/grade-school/GradeSchoolTest.cs +++ b/exercises/grade-school/GradeSchoolTest.cs @@ -1,81 +1,61 @@ -using System.Collections.Generic; -using NUnit.Framework; +using Xunit; -[TestFixture] public class GradeSchoolTest { - private School school; - - [SetUp] - public void Setup() - { - school = new School(); - } - - [Test] - public void New_school_has_an_empty_roster() - { - Assert.That(school.Roster, Has.Count.EqualTo(0)); - } - - [Ignore("Remove to run test")] - [Test] + private readonly School school = new School(); + + [Fact] public void Adding_a_student_adds_them_to_the_roster_for_the_given_grade() { school.Add("Aimee", 2); - var expected = new List { "Aimee" }; - Assert.That(school.Roster[2], Is.EqualTo(expected)); + var expected = new [] { "Aimee" }; + Assert.Equal(expected, school.Roster(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Adding_more_students_to_the_same_grade_adds_them_to_the_roster() { school.Add("Blair", 2); school.Add("James", 2); school.Add("Paul", 2); - var expected = new List { "Blair", "James", "Paul" }; - Assert.That(school.Roster[2], Is.EqualTo(expected)); + var expected = new [] { "Blair", "James", "Paul" }; + Assert.Equal(expected, school.Roster(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Adding_students_to_different_grades_adds_them_to_the_roster() { school.Add("Chelsea", 3); school.Add("Logan", 7); - Assert.That(school.Roster[3], Is.EqualTo(new List { "Chelsea" })); - Assert.That(school.Roster[7], Is.EqualTo(new List { "Logan" })); + Assert.Equal(new [] { "Chelsea" }, school.Roster(3)); + Assert.Equal(new [] { "Logan" }, school.Roster(7)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Grade_returns_the_students_in_that_grade_in_alphabetical_order() { school.Add("Franklin", 5); school.Add("Bradley", 5); school.Add("Jeff", 1); - var expected = new List { "Bradley", "Franklin" }; - Assert.That(school.Grade(5), Is.EqualTo(expected)); + var expected = new [] { "Bradley", "Franklin" }; + Assert.Equal(expected, school.Grade(5)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Grade_returns_an_empty_list_if_there_are_no_students_in_that_grade() { - Assert.That(school.Grade(1), Is.EqualTo(new List())); + Assert.Empty(school.Grade(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Student_names_in_each_grade_in_roster_are_sorted() { school.Add("Jennifer", 4); school.Add("Kareem", 6); school.Add("Christopher", 4); school.Add("Kyle", 3); - Assert.That(school.Roster[3], Is.EqualTo(new List { "Kyle" })); - Assert.That(school.Roster[4], Is.EqualTo(new List { "Christopher", "Jennifer" })); - Assert.That(school.Roster[6], Is.EqualTo(new List { "Kareem" })); + Assert.Equal(new [] { "Kyle" }, school.Roster(3)); + Assert.Equal(new [] { "Christopher", "Jennifer" }, school.Roster(4)); + Assert.Equal(new [] { "Kareem" }, school.Roster(6)); } } \ No newline at end of file diff --git a/exercises/grains/GrainsTest.cs b/exercises/grains/GrainsTest.cs index b540e25576..c02f35c2b3 100644 --- a/exercises/grains/GrainsTest.cs +++ b/exercises/grains/GrainsTest.cs @@ -1,60 +1,52 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class GrainsTest { - [Test] + [Fact] public void Test_square_1() { - Assert.That(Grains.Square(1), Is.EqualTo(1)); + Assert.Equal(1ul, Grains.Square(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_2() { - Assert.That(Grains.Square(2), Is.EqualTo(2)); + Assert.Equal(2ul, Grains.Square(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_3() { - Assert.That(Grains.Square(3), Is.EqualTo(4)); + Assert.Equal(4ul, Grains.Square(3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_4() { - Assert.That(Grains.Square(4), Is.EqualTo(8)); + Assert.Equal(8ul, Grains.Square(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_16() { - Assert.That(Grains.Square(16), Is.EqualTo(32768)); + Assert.Equal(32768ul, Grains.Square(16)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_32() { - Assert.That(Grains.Square(32), Is.EqualTo(2147483648)); + Assert.Equal(2147483648ul, Grains.Square(32)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_square_64() { - Assert.That(Grains.Square(64), Is.EqualTo(9223372036854775808)); + Assert.Equal(9223372036854775808ul, Grains.Square(64)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_total_grains() { - Assert.That(Grains.Total(), Is.EqualTo(18446744073709551615)); + Assert.Equal(18446744073709551615ul, Grains.Total()); } } \ No newline at end of file diff --git a/exercises/grep/GrepTest.cs b/exercises/grep/GrepTest.cs index b3538fbd5b..7fff8ebcf0 100644 --- a/exercises/grep/GrepTest.cs +++ b/exercises/grep/GrepTest.cs @@ -1,7 +1,8 @@ -using System.IO; -using NUnit.Framework; +using System; +using System.IO; +using Xunit; -public class GrepTest +public class GrepTest : IDisposable { private const string IliadFileName = "iliad.txt"; private const string IliadContents = @@ -38,18 +39,16 @@ If I refuse to wed Demetrius. Of Oreb, or of Sinai, didst inspire That Shepherd, who first taught the chosen Seed "; - - [OneTimeSetUp] - public void SetUp() + + public GrepTest() { Directory.SetCurrentDirectory(Path.GetTempPath()); File.WriteAllText(IliadFileName, IliadContents); File.WriteAllText(MidsummerNightFileName, MidsummerNightContents); File.WriteAllText(ParadiseLostFileName, ParadiseLostContents); } - - [OneTimeTearDown] - public void TearDown() + + public void Dispose() { Directory.SetCurrentDirectory(Path.GetTempPath()); File.Delete(IliadFileName); @@ -57,7 +56,7 @@ public void TearDown() File.Delete(ParadiseLostFileName); } - [Test] + [Fact] public void One_file_one_match_no_flags() { const string pattern = "Agamemnon"; @@ -67,11 +66,10 @@ public void One_file_one_match_no_flags() const string expected = "Of Atreus, Agamemnon, King of men.\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_one_match_print_line_numbers_flag() { const string pattern = "Forbidden"; @@ -81,11 +79,10 @@ public void One_file_one_match_print_line_numbers_flag() const string expected = "2:Of that Forbidden Tree, whose mortal tast\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_one_match_case_insensitive_flag() { const string pattern = "Forbidden"; @@ -95,11 +92,10 @@ public void One_file_one_match_case_insensitive_flag() const string expected = "Of that Forbidden Tree, whose mortal tast\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_one_match_print_file_names_flag() { const string pattern = "Forbidden"; @@ -109,11 +105,10 @@ public void One_file_one_match_print_file_names_flag() var expected = $"{ParadiseLostFileName}\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_one_match_match_entire_lines_flag() { const string pattern = "With loss of Eden, till one greater Man"; @@ -123,11 +118,10 @@ public void One_file_one_match_match_entire_lines_flag() const string expected = "With loss of Eden, till one greater Man\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_one_match_multiple_flags() { const string pattern = "OF ATREUS, Agamemnon, KIng of MEN."; @@ -136,11 +130,10 @@ public void One_file_one_match_multiple_flags() const string expected = "9:Of Atreus, Agamemnon, King of men.\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_several_matches_no_flags() { const string pattern = "may"; @@ -152,11 +145,10 @@ public void One_file_several_matches_no_flags() "But I beseech your grace that I may know\n" + "The worst that may befall me in this case,\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_several_matches_print_line_numbers_flag() { const string pattern = "may"; @@ -168,11 +160,10 @@ public void One_file_several_matches_print_line_numbers_flag() "5:But I beseech your grace that I may know\n" + "6:The worst that may befall me in this case,\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_several_matches_match_entire_lines_flag() { const string pattern = "may"; @@ -181,11 +172,10 @@ public void One_file_several_matches_match_entire_lines_flag() const string expected = ""; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_several_matches_case_insensitive_flag() { const string pattern = "ACHILLES"; @@ -196,11 +186,10 @@ public void One_file_several_matches_case_insensitive_flag() "Achilles sing, O Goddess! Peleus' son;\n" + "The noble Chief Achilles from the son\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_file_several_matches_inverted_flag() { const string pattern = "Of"; @@ -214,26 +203,26 @@ public void One_file_several_matches_inverted_flag() "Sing Heav'nly Muse, that on the secret top\n" + "That Shepherd, who first taught the chosen Seed\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [TestCase("", Ignore = "Remove to run test case")] - [TestCase("-n", Ignore = "Remove to run test case")] - [TestCase("-l", Ignore = "Remove to run test case")] - [TestCase("-x", Ignore = "Remove to run test case")] - [TestCase("-i", Ignore = "Remove to run test case")] - [TestCase("-n -l -x -i", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("")] + [InlineData("-n")] + [InlineData("-l")] + [InlineData("-x")] + [InlineData("-i")] + [InlineData("-n -l -x -i")] public void One_file_no_matches_various_flags(string flags) { const string pattern = "Gandalf"; var files = new[] { IliadFileName }; const string expected = ""; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_one_match_no_flags() { const string pattern = "Agamemnon"; @@ -243,11 +232,10 @@ public void Multiple_files_one_match_no_flags() var expected = $"{IliadFileName}:Of Atreus, Agamemnon, King of men.\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_several_matches_no_flags() { const string pattern = "may"; @@ -259,11 +247,10 @@ public void Multiple_files_several_matches_no_flags() $"{MidsummerNightFileName}:But I beseech your grace that I may know\n" + $"{MidsummerNightFileName}:The worst that may befall me in this case,\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_several_matches_print_line_numbers_flag() { const string pattern = "that"; @@ -276,11 +263,10 @@ public void Multiple_files_several_matches_print_line_numbers_flag() $"{ParadiseLostFileName}:2:Of that Forbidden Tree, whose mortal tast\n" + $"{ParadiseLostFileName}:6:Sing Heav'nly Muse, that on the secret top\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_several_matches_print_file_names_flag() { const string pattern = "who"; @@ -291,11 +277,10 @@ public void Multiple_files_several_matches_print_file_names_flag() $"{IliadFileName}\n" + $"{ParadiseLostFileName}\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_several_matches_case_insensitive_flag() { const string pattern = "TO"; @@ -314,11 +299,10 @@ public void Multiple_files_several_matches_case_insensitive_flag() $"{ParadiseLostFileName}:Restore us, and regain the blissful Seat,\n" + $"{ParadiseLostFileName}:Sing Heav'nly Muse, that on the secret top\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_several_matches_inverted_flag() { const string pattern = "a"; @@ -330,11 +314,10 @@ public void Multiple_files_several_matches_inverted_flag() $"{IliadFileName}:The noble Chief Achilles from the son\n" + $"{MidsummerNightFileName}:If I refuse to wed Demetrius.\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_one_match_match_entire_lines_flag() { const string pattern = "But I beseech your grace that I may know"; @@ -344,11 +327,10 @@ public void Multiple_files_one_match_match_entire_lines_flag() var expected = $"{MidsummerNightFileName}:But I beseech your grace that I may know\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_files_one_match_multiple_flags() { const string pattern = "WITH LOSS OF EDEN, TILL ONE GREATER MAN"; @@ -357,15 +339,16 @@ public void Multiple_files_one_match_multiple_flags() var expected = $"{ParadiseLostFileName}:4:With loss of Eden, till one greater Man\n"; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } - [TestCase("", Ignore = "Remove to run test case")] - [TestCase("-n", Ignore = "Remove to run test case")] - [TestCase("-l", Ignore = "Remove to run test case")] - [TestCase("-x", Ignore = "Remove to run test case")] - [TestCase("-i", Ignore = "Remove to run test case")] - [TestCase("-n -l -x -i", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("")] + [InlineData("-n")] + [InlineData("-l")] + [InlineData("-x")] + [InlineData("-i")] + [InlineData("-n -l -x -i")] public void Multiple_files_no_matches_various_flags(string flags) { const string pattern = "Frodo"; @@ -373,6 +356,6 @@ public void Multiple_files_no_matches_various_flags(string flags) const string expected = ""; - Assert.That(Grep.Find(pattern, flags, files), Is.EqualTo(expected)); + Assert.Equal(expected, Grep.Find(pattern, flags, files)); } } \ No newline at end of file diff --git a/exercises/hamming/HammingTest.cs b/exercises/hamming/HammingTest.cs index 30551e5c69..68cce26120 100644 --- a/exercises/hamming/HammingTest.cs +++ b/exercises/hamming/HammingTest.cs @@ -1,46 +1,40 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class HammingTest { - [Test] + [Fact] public void No_difference_between_empty_strands() { - Assert.That(Hamming.Compute("",""), Is.EqualTo(0)); + Assert.Equal(0, Hamming.Compute("","")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void No_difference_between_identical_strands() { - Assert.That(Hamming.Compute("GGACTGA","GGACTGA"), Is.EqualTo(0)); + Assert.Equal(0, Hamming.Compute("GGACTGA","GGACTGA")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Complete_hamming_distance_in_small_strand() { - Assert.That(Hamming.Compute("ACT","GGA"), Is.EqualTo(3)); + Assert.Equal(3, Hamming.Compute("ACT","GGA")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Hamming_distance_is_off_by_one_strand() { - Assert.That(Hamming.Compute("GGACGGATTCTG","AGGACGGATTCT"), Is.EqualTo(9)); + Assert.Equal(9, Hamming.Compute("GGACGGATTCTG","AGGACGGATTCT")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Smalling_hamming_distance_in_middle_somewhere() { - Assert.That(Hamming.Compute("GGACG","GGTCG"), Is.EqualTo(1)); + Assert.Equal(1, Hamming.Compute("GGACG","GGTCG")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Larger_distance() { - Assert.That(Hamming.Compute("ACCAGGG","ACTATGG"), Is.EqualTo(2)); + Assert.Equal(2, Hamming.Compute("ACCAGGG","ACTATGG")); } } \ No newline at end of file diff --git a/exercises/hangman/HangmanTest.cs b/exercises/hangman/HangmanTest.cs index 1c8693f5a5..9678a26911 100644 --- a/exercises/hangman/HangmanTest.cs +++ b/exercises/hangman/HangmanTest.cs @@ -1,8 +1,8 @@ -using NUnit.Framework; +using Xunit; public class HangmanTest { - [Test] + [Fact] public void Initially_9_failures_are_allowed() { var game = new HangmanGame("foo"); @@ -12,12 +12,11 @@ public void Initially_9_failures_are_allowed() game.Start(); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(9)); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(9, lastState.RemainingGuesses); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Initially_no_letters_are_guessed() { var game = new HangmanGame("foo"); @@ -27,11 +26,10 @@ public void Initially_no_letters_are_guessed() game.Start(); - Assert.That(lastState.MaskedWord, Is.EqualTo("___")); + Assert.Equal("___", lastState.MaskedWord); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void After_10_failures_the_game_is_over() { var game = new HangmanGame("foo"); @@ -46,11 +44,10 @@ public void After_10_failures_the_game_is_over() game.Guess('x'); } - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Lose)); + Assert.Equal(HangmanGame.Status.Lose, lastState.Status); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Feeding_a_correct_letter_removes_underscores() { var game = new HangmanGame("foobar"); @@ -62,19 +59,18 @@ public void Feeding_a_correct_letter_removes_underscores() game.Guess('b'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(9)); - Assert.That(lastState.MaskedWord, Is.EqualTo("___b__")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(9, lastState.RemainingGuesses); + Assert.Equal("___b__", lastState.MaskedWord); game.Guess('o'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(9)); - Assert.That(lastState.MaskedWord, Is.EqualTo("_oob__")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(9, lastState.RemainingGuesses); + Assert.Equal("_oob__", lastState.MaskedWord); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Feeding_a_correct_letter_twice_counts_as_a_failure() { var game = new HangmanGame("foobar"); @@ -86,19 +82,18 @@ public void Feeding_a_correct_letter_twice_counts_as_a_failure() game.Guess('b'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(9)); - Assert.That(lastState.MaskedWord, Is.EqualTo("___b__")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(9, lastState.RemainingGuesses); + Assert.Equal("___b__", lastState.MaskedWord); game.Guess('b'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(8)); - Assert.That(lastState.MaskedWord, Is.EqualTo("___b__")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(8, lastState.RemainingGuesses); + Assert.Equal("___b__", lastState.MaskedWord); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Getting_all_the_letters_right_makes_for_a_win() { var game = new HangmanGame("hello"); @@ -110,31 +105,31 @@ public void Getting_all_the_letters_right_makes_for_a_win() game.Guess('b'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(8)); - Assert.That(lastState.MaskedWord, Is.EqualTo("_____")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(8, lastState.RemainingGuesses); + Assert.Equal("_____", lastState.MaskedWord); game.Guess('e'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(8)); - Assert.That(lastState.MaskedWord, Is.EqualTo("_e___")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(8, lastState.RemainingGuesses); + Assert.Equal("_e___", lastState.MaskedWord); game.Guess('l'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(8)); - Assert.That(lastState.MaskedWord, Is.EqualTo("_ell_")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(8, lastState.RemainingGuesses); + Assert.Equal("_ell_", lastState.MaskedWord); game.Guess('o'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Busy)); - Assert.That(lastState.RemainingGuesses, Is.EqualTo(8)); - Assert.That(lastState.MaskedWord, Is.EqualTo("_ello")); + Assert.Equal(HangmanGame.Status.Busy, lastState.Status); + Assert.Equal(8, lastState.RemainingGuesses); + Assert.Equal("_ello", lastState.MaskedWord); game.Guess('h'); - Assert.That(lastState.Status, Is.EqualTo(HangmanGame.Status.Win)); - Assert.That(lastState.MaskedWord, Is.EqualTo("hello")); + Assert.Equal(HangmanGame.Status.Win, lastState.Status); + Assert.Equal("hello", lastState.MaskedWord); } } \ No newline at end of file diff --git a/exercises/hello-world/HelloWorldTest.cs b/exercises/hello-world/HelloWorldTest.cs index 8361b022e8..7a245f56ec 100644 --- a/exercises/hello-world/HelloWorldTest.cs +++ b/exercises/hello-world/HelloWorldTest.cs @@ -1,25 +1,22 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class HelloWorldTest { - [Test] + [Fact] public void No_name() { - Assert.That(HelloWorld.Hello(null), Is.EqualTo("Hello, World!")); + Assert.Equal("Hello, World!", HelloWorld.Hello(null)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sample_name() { - Assert.That(HelloWorld.Hello("Alice"), Is.EqualTo("Hello, Alice!")); + Assert.Equal("Hello, Alice!", HelloWorld.Hello("Alice")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Other_sample_name() { - Assert.That(HelloWorld.Hello("Bob"), Is.EqualTo("Hello, Bob!")); + Assert.Equal("Hello, Bob!", HelloWorld.Hello("Bob")); } } diff --git a/exercises/house/HouseTest.cs b/exercises/house/HouseTest.cs index 4ff6d6f2bd..69a10760ab 100644 --- a/exercises/house/HouseTest.cs +++ b/exercises/house/HouseTest.cs @@ -1,8 +1,8 @@ -using NUnit.Framework; +using Xunit; public class HouseTest { - [Test] + [Fact] public void Rhyme_is_correct() { const string expected = @@ -96,6 +96,6 @@ public void Rhyme_is_correct() "that ate the malt\n" + "that lay in the house that Jack built."; - Assert.That(House.Rhyme(), Is.EqualTo(expected)); + Assert.Equal(expected, House.Rhyme()); } } \ No newline at end of file diff --git a/exercises/isogram/IsogramTest.cs b/exercises/isogram/IsogramTest.cs index 9f51ae09f5..bb22e6afd9 100644 --- a/exercises/isogram/IsogramTest.cs +++ b/exercises/isogram/IsogramTest.cs @@ -1,20 +1,20 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class IsogramTest { - [TestCase("duplicates", ExpectedResult = true)] - [TestCase("eleven", ExpectedResult = false, Ignore = "Remove to run test case")] - [TestCase("subdermatoglyphic", ExpectedResult = true, Ignore = "Remove to run test case")] - [TestCase("Alphabet", ExpectedResult = false, Ignore = "Remove to run test case")] - [TestCase("thumbscrew-japingly", ExpectedResult = true, Ignore = "Remove to run test case")] - [TestCase("Hjelmqvist-Gryb-Zock-Pfund-Wax", ExpectedResult = true, Ignore = "Remove to run test case")] - [TestCase("Heizölrückstoßabdämpfung", ExpectedResult = true, Ignore = "Remove to run test case")] - [TestCase("the quick brown fox", ExpectedResult = false, Ignore = "Remove to run test case")] - [TestCase("Emily Jung Schwartzkopf", ExpectedResult = true, Ignore = "Remove to run test case")] - [TestCase("éléphant", ExpectedResult = false, Ignore = "Remove to run test case")] - public bool Isogram_correctly_detects_isograms(string input) + [Theory] + [InlineData("duplicates", true)] + [InlineData("eleven", false)] + [InlineData("subdermatoglyphic", true)] + [InlineData("Alphabet", false)] + [InlineData("thumbscrew-japingly", true)] + [InlineData("Hjelmqvist-Gryb-Zock-Pfund-Wax", true)] + [InlineData("Heizölrückstoßabdämpfung", true)] + [InlineData("the quick brown fox", false)] + [InlineData("Emily Jung Schwartzkopf", true)] + [InlineData("éléphant", false)] + public void Isogram_correctly_detects_isograms(string input, bool expected) { - return Isogram.IsIsogram(input); + Assert.Equal(expected, Isogram.IsIsogram(input)); } } \ No newline at end of file diff --git a/exercises/kindergarten-garden/KinderGartenGardenTest.cs b/exercises/kindergarten-garden/KinderGartenGardenTest.cs index 0c419aa364..6e16480c59 100644 --- a/exercises/kindergarten-garden/KinderGartenGardenTest.cs +++ b/exercises/kindergarten-garden/KinderGartenGardenTest.cs @@ -1,65 +1,60 @@ -using NUnit.Framework; +using Xunit; public class KinderGartenGardenTest { - [Test] + [Fact] public void Missing_child() { var actual = Garden.DefaultGarden("RC\nGG").GetPlants("Potter"); - Assert.That(actual, Is.Empty); + Assert.Empty(actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Alice() { - Assert.That(Garden.DefaultGarden("RC\nGG").GetPlants("Alice"), Is.EqualTo(new [] { Plant.Radishes, Plant.Clover, Plant.Grass, Plant.Grass })); - Assert.That(Garden.DefaultGarden("VC\nRC").GetPlants("Alice"), Is.EqualTo(new[] { Plant.Violets, Plant.Clover, Plant.Radishes, Plant.Clover })); + Assert.Equal(new [] { Plant.Radishes, Plant.Clover, Plant.Grass, Plant.Grass }, Garden.DefaultGarden("RC\nGG").GetPlants("Alice")); + Assert.Equal(new[] { Plant.Violets, Plant.Clover, Plant.Radishes, Plant.Clover }, Garden.DefaultGarden("VC\nRC").GetPlants("Alice")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Small_garden() { var actual = Garden.DefaultGarden("VVCG\nVVRC").GetPlants("Bob"); - Assert.That(actual, Is.EqualTo(new[] { Plant.Clover, Plant.Grass, Plant.Radishes, Plant.Clover })); + Assert.Equal(new[] { Plant.Clover, Plant.Grass, Plant.Radishes, Plant.Clover }, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Medium_garden() { var garden = Garden.DefaultGarden("VVCCGG\nVVCCGG"); - Assert.That(garden.GetPlants("Bob"), Is.EqualTo(new[] { Plant.Clover, Plant.Clover, Plant.Clover, Plant.Clover })); - Assert.That(garden.GetPlants("Charlie"), Is.EqualTo(new[] { Plant.Grass, Plant.Grass, Plant.Grass, Plant.Grass })); + Assert.Equal(new[] { Plant.Clover, Plant.Clover, Plant.Clover, Plant.Clover }, garden.GetPlants("Bob")); + Assert.Equal(new[] { Plant.Grass, Plant.Grass, Plant.Grass, Plant.Grass }, garden.GetPlants("Charlie")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Full_garden() { var garden = Garden.DefaultGarden("VRCGVVRVCGGCCGVRGCVCGCGV\nVRCCCGCRRGVCGCRVVCVGCGCV"); - Assert.That(garden.GetPlants("Alice"), Is.EqualTo(new[] { Plant.Violets, Plant.Radishes, Plant.Violets, Plant.Radishes })); - Assert.That(garden.GetPlants("Bob"), Is.EqualTo(new[] { Plant.Clover, Plant.Grass, Plant.Clover, Plant.Clover })); - Assert.That(garden.GetPlants("David"), Is.EqualTo(new[] { Plant.Radishes, Plant.Violets, Plant.Clover, Plant.Radishes })); - Assert.That(garden.GetPlants("Eve"), Is.EqualTo(new[] { Plant.Clover, Plant.Grass, Plant.Radishes, Plant.Grass })); - Assert.That(garden.GetPlants("Fred"), Is.EqualTo(new[] { Plant.Grass, Plant.Clover, Plant.Violets, Plant.Clover })); - Assert.That(garden.GetPlants("Ginny"), Is.EqualTo(new[] { Plant.Clover, Plant.Grass, Plant.Grass, Plant.Clover })); - Assert.That(garden.GetPlants("Harriet"), Is.EqualTo(new[] { Plant.Violets, Plant.Radishes, Plant.Radishes, Plant.Violets })); - Assert.That(garden.GetPlants("Ileana"), Is.EqualTo(new[] { Plant.Grass, Plant.Clover, Plant.Violets, Plant.Clover })); - Assert.That(garden.GetPlants("Joseph"), Is.EqualTo(new[] { Plant.Violets, Plant.Clover, Plant.Violets, Plant.Grass })); - Assert.That(garden.GetPlants("Kincaid"), Is.EqualTo(new[] { Plant.Grass, Plant.Clover, Plant.Clover, Plant.Grass })); - Assert.That(garden.GetPlants("Larry"), Is.EqualTo(new[] { Plant.Grass, Plant.Violets, Plant.Clover, Plant.Violets })); + Assert.Equal(new[] { Plant.Violets, Plant.Radishes, Plant.Violets, Plant.Radishes }, garden.GetPlants("Alice")); + Assert.Equal(new[] { Plant.Clover, Plant.Grass, Plant.Clover, Plant.Clover }, garden.GetPlants("Bob")); + Assert.Equal(new[] { Plant.Radishes, Plant.Violets, Plant.Clover, Plant.Radishes }, garden.GetPlants("David")); + Assert.Equal(new[] { Plant.Clover, Plant.Grass, Plant.Radishes, Plant.Grass }, garden.GetPlants("Eve")); + Assert.Equal(new[] { Plant.Grass, Plant.Clover, Plant.Violets, Plant.Clover }, garden.GetPlants("Fred")); + Assert.Equal(new[] { Plant.Clover, Plant.Grass, Plant.Grass, Plant.Clover }, garden.GetPlants("Ginny")); + Assert.Equal(new[] { Plant.Violets, Plant.Radishes, Plant.Radishes, Plant.Violets }, garden.GetPlants("Harriet")); + Assert.Equal(new[] { Plant.Grass, Plant.Clover, Plant.Violets, Plant.Clover }, garden.GetPlants("Ileana")); + Assert.Equal(new[] { Plant.Violets, Plant.Clover, Plant.Violets, Plant.Grass }, garden.GetPlants("Joseph")); + Assert.Equal(new[] { Plant.Grass, Plant.Clover, Plant.Clover, Plant.Grass }, garden.GetPlants("Kincaid")); + Assert.Equal(new[] { Plant.Grass, Plant.Violets, Plant.Clover, Plant.Violets }, garden.GetPlants("Larry")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Surprise_garden() { var garden = new Garden(new [] { "Samantha", "Patricia", "Xander", "Roger" }, "VCRRGVRG\nRVGCCGCV"); - Assert.That(garden.GetPlants("Patricia"), Is.EqualTo(new[] { Plant.Violets, Plant.Clover, Plant.Radishes, Plant.Violets })); - Assert.That(garden.GetPlants("Roger"), Is.EqualTo(new[] { Plant.Radishes, Plant.Radishes, Plant.Grass, Plant.Clover })); - Assert.That(garden.GetPlants("Samantha"), Is.EqualTo(new[] { Plant.Grass, Plant.Violets, Plant.Clover, Plant.Grass })); - Assert.That(garden.GetPlants("Xander"), Is.EqualTo(new[] { Plant.Radishes, Plant.Grass, Plant.Clover, Plant.Violets })); + Assert.Equal(new[] { Plant.Violets, Plant.Clover, Plant.Radishes, Plant.Violets }, garden.GetPlants("Patricia")); + Assert.Equal(new[] { Plant.Radishes, Plant.Radishes, Plant.Grass, Plant.Clover }, garden.GetPlants("Roger")); + Assert.Equal(new[] { Plant.Grass, Plant.Violets, Plant.Clover, Plant.Grass }, garden.GetPlants("Samantha")); + Assert.Equal(new[] { Plant.Radishes, Plant.Grass, Plant.Clover, Plant.Violets }, garden.GetPlants("Xander")); } } \ No newline at end of file diff --git a/exercises/largest-series-product/LargestSeriesProductTest.cs b/exercises/largest-series-product/LargestSeriesProductTest.cs index 996532e66b..d891dbd050 100644 --- a/exercises/largest-series-product/LargestSeriesProductTest.cs +++ b/exercises/largest-series-product/LargestSeriesProductTest.cs @@ -1,153 +1,139 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class LargestSeriesProductTest { - [Test] + [Fact] public void Can_find_the_largest_product_of_2_with_numbers_in_order() { const string digits = "0123456789"; const int span = 2; const int expected = 72; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_find_the_largest_product_of_2() { const string digits = "576802143"; const int span = 2; const int expected = 48; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Finds_the_largest_product_if_span_equals_length() { const string digits = "29"; const int span = 2; const int expected = 18; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_find_the_largest_product_of_3_with_numbers_in_order() { const string digits = "0123456789"; const int span = 3; const int expected = 504; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_find_the_largest_product_of_3() { const string digits = "1027839564"; const int span = 3; const int expected = 270; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_find_the_largest_product_of_5_with_numbers_in_order() { const string digits = "0123456789"; const int span = 5; const int expected = 15120; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_get_the_largest_product_of_a_big_number() { const string digits = "73167176531330624919225119674426574742355349194934"; const int span = 6; const int expected = 23520; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_get_the_largest_product_of_a_big_number_II() { const string digits = "52677741234314237566414902593461595376319419139427"; const int span = 6; const int expected = 28350; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_get_the_largest_product_of_a_big_number_III() { const string digits = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450"; const int span = 13; const long expected = 23514624000; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reports_zero_if_the_only_digits_are_zero() { const string digits = "0000"; const int span = 2; const int expected = 0; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reports_zero_if_all_spans_include_zero() { const string digits = "99099"; const int span = 3; const int expected = 0; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reports_1_for_empty_string_and_empty_product_0_span() { const string digits = ""; const int span = 0; const int expected = 1; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reports_1_for_nonempty_string_and_empty_product_0_span() { const string digits = "123"; const int span = 0; const int expected = 1; - Assert.That(LargestSeriesProduct.GetLargestProduct(digits, span), Is.EqualTo(expected)); + Assert.Equal(expected, LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rejects_span_longer_than_string_length() { const string digits = "123"; @@ -156,8 +142,7 @@ public void Rejects_span_longer_than_string_length() Assert.Throws(() => LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rejects_empty_string_and_nonzero_span() { const string digits = ""; @@ -166,8 +151,7 @@ public void Rejects_empty_string_and_nonzero_span() Assert.Throws(() => LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rejects_invalid_character_in_digits() { const string digits = "1234a5"; @@ -176,8 +160,7 @@ public void Rejects_invalid_character_in_digits() Assert.Throws(() => LargestSeriesProduct.GetLargestProduct(digits, span)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rejects_negative_span() { const string digits = "12345"; diff --git a/exercises/leap/LeapTest.cs b/exercises/leap/LeapTest.cs index 255f4f02e1..937717e055 100644 --- a/exercises/leap/LeapTest.cs +++ b/exercises/leap/LeapTest.cs @@ -1,32 +1,28 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class LeapTest { - [Test] + [Fact] public void Valid_leap_year() { - Assert.That(Year.IsLeap(1996), Is.True); + Assert.True(Year.IsLeap(1996)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Invalid_leap_year() { - Assert.That(Year.IsLeap(1997), Is.False); + Assert.False(Year.IsLeap(1997)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Turn_of_the_20th_century_is_not_a_leap_year() { - Assert.That(Year.IsLeap(1900), Is.False); + Assert.False(Year.IsLeap(1900)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Turn_of_the_25th_century_is_a_leap_year() { - Assert.That(Year.IsLeap(2400), Is.True); + Assert.True(Year.IsLeap(2400)); } } \ No newline at end of file diff --git a/exercises/ledger/LedgerTest.cs b/exercises/ledger/LedgerTest.cs index bf568201e3..2b6ec6bf3c 100644 --- a/exercises/ledger/LedgerTest.cs +++ b/exercises/ledger/LedgerTest.cs @@ -1,8 +1,8 @@ -using NUnit.Framework; +using Xunit; public class LedgerTest { - [Test] + [Fact] public void Empty_ledger() { var currency = "USD"; @@ -11,10 +11,10 @@ public void Empty_ledger() var expected = "Date | Description | Change "; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void One_entry() { var currency = "USD"; @@ -27,10 +27,10 @@ public void One_entry() "Date | Description | Change \n" + "01/01/2015 | Buy present | ($10.00)"; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Credit_and_debit() { var currency = "USD"; @@ -45,10 +45,10 @@ public void Credit_and_debit() "01/01/2015 | Buy present | ($10.00)\n" + "01/02/2015 | Get present | $10.00 "; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_entries_on_same_date_ordered_by_description() { var currency = "USD"; @@ -63,10 +63,10 @@ public void Multiple_entries_on_same_date_ordered_by_description() "01/01/2015 | Buy present | ($10.00)\n" + "01/01/2015 | Get present | $10.00 "; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Final_order_tie_breaker_is_change() { var currency = "USD"; @@ -83,10 +83,10 @@ public void Final_order_tie_breaker_is_change() "01/01/2015 | Something | $0.00 \n" + "01/01/2015 | Something | $0.01 "; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Overlong_descriptions() { var currency = "USD"; @@ -99,10 +99,10 @@ public void Overlong_descriptions() "Date | Description | Change \n" + "01/01/2015 | Freude schoner Gotterf... | ($1,234.56)"; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Euros() { var currency = "EUR"; @@ -115,10 +115,10 @@ public void Euros() "Date | Description | Change \n" + "01/01/2015 | Buy present | (€10.00)"; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Dutch_locale() { var currency = "USD"; @@ -131,10 +131,10 @@ public void Dutch_locale() "Datum | Omschrijving | Verandering \n" + "12-03-2015 | Buy present | $ 1.234,56 "; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Dutch_negative_number_with_3_digits_before_decimal_point() { var currency = "USD"; @@ -147,10 +147,10 @@ public void Dutch_negative_number_with_3_digits_before_decimal_point() "Datum | Omschrijving | Verandering \n" + "12-03-2015 | Buy present | $ -123,45"; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } - [Test] + [Fact(Skip = "Remove to run test")] public void American_negative_number_with_3_digits_before_decimal_point() { var currency = "USD"; @@ -163,6 +163,6 @@ public void American_negative_number_with_3_digits_before_decimal_point() "Date | Description | Change \n" + "03/12/2015 | Buy present | ($123.45)"; - Assert.That(Ledger.Format(currency, locale, entries), Is.EqualTo(expected)); + Assert.Equal(expected, Ledger.Format(currency, locale, entries)); } } \ No newline at end of file diff --git a/exercises/linked-list/LinkedListTest.cs b/exercises/linked-list/LinkedListTest.cs index 135a47de27..c625a80111 100644 --- a/exercises/linked-list/LinkedListTest.cs +++ b/exercises/linked-list/LinkedListTest.cs @@ -1,94 +1,81 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class DequeTest { - private Deque deque; + private readonly Deque deque = new Deque(); - [SetUp] - public void Setup() - { - deque = new Deque(); - } - - [Test] + [Fact] public void Push_and_pop_are_first_in_last_out_order() { deque.Push(10); deque.Push(20); - Assert.That(deque.Pop(), Is.EqualTo(20)); - Assert.That(deque.Pop(), Is.EqualTo(10)); + Assert.Equal(20, deque.Pop()); + Assert.Equal(10, deque.Pop()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Push_and_shift_are_first_in_first_out_order() { deque.Push(10); deque.Push(20); - Assert.That(deque.Shift(), Is.EqualTo(10)); - Assert.That(deque.Shift(), Is.EqualTo(20)); + Assert.Equal(10, deque.Shift()); + Assert.Equal(20, deque.Shift()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Unshift_and_shift_are_last_in_first_out_order() { deque.Unshift(10); deque.Unshift(20); - Assert.That(deque.Shift(), Is.EqualTo(20)); - Assert.That(deque.Shift(), Is.EqualTo(10)); + Assert.Equal(20, deque.Shift()); + Assert.Equal(10, deque.Shift()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Unshift_and_pop_are_last_in_last_out_order() { deque.Unshift(10); deque.Unshift(20); - Assert.That(deque.Pop(), Is.EqualTo(10)); - Assert.That(deque.Pop(), Is.EqualTo(20)); + Assert.Equal(10, deque.Pop()); + Assert.Equal(20, deque.Pop()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Push_and_pop_can_handle_multiple_values() { deque.Push(10); deque.Push(20); deque.Push(30); - Assert.That(deque.Pop(), Is.EqualTo(30)); - Assert.That(deque.Pop(), Is.EqualTo(20)); - Assert.That(deque.Pop(), Is.EqualTo(10)); + Assert.Equal(30, deque.Pop()); + Assert.Equal(20, deque.Pop()); + Assert.Equal(10, deque.Pop()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Unshift_and_shift_can_handle_multiple_values() { deque.Unshift(10); deque.Unshift(20); deque.Unshift(30); - Assert.That(deque.Shift(), Is.EqualTo(30)); - Assert.That(deque.Shift(), Is.EqualTo(20)); - Assert.That(deque.Shift(), Is.EqualTo(10)); + Assert.Equal(30, deque.Shift()); + Assert.Equal(20, deque.Shift()); + Assert.Equal(10, deque.Shift()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void All_methods_of_manipulating_the_deque_can_be_used_together() { deque.Push(10); deque.Push(20); - Assert.That(deque.Pop(), Is.EqualTo(20)); + Assert.Equal(20, deque.Pop()); deque.Push(30); - Assert.That(deque.Shift(), Is.EqualTo(10)); + Assert.Equal(10, deque.Shift()); deque.Unshift(40); deque.Push(50); - Assert.That(deque.Shift(), Is.EqualTo(40)); - Assert.That(deque.Pop(), Is.EqualTo(50)); - Assert.That(deque.Shift(), Is.EqualTo(30)); + Assert.Equal(40, deque.Shift()); + Assert.Equal(50, deque.Pop()); + Assert.Equal(30, deque.Shift()); } } \ No newline at end of file diff --git a/exercises/list-ops/ListOpsTest.cs b/exercises/list-ops/ListOpsTest.cs index 68dfbd3d53..68ce0414cb 100644 --- a/exercises/list-ops/ListOpsTest.cs +++ b/exercises/list-ops/ListOpsTest.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; public class ListOpsTest { @@ -19,177 +19,154 @@ private static List Cons(T x, List input) return list; } - [Test] + [Fact] public void LengthOfEmptyList() { - Assert.That(ListOps.Length(EmptyList), Is.EqualTo(0)); + Assert.Equal(0, ListOps.Length(EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void LengthOfNonEmptyList() { - Assert.That(ListOps.Length(Range(1, 4)), Is.EqualTo(4)); + Assert.Equal(4, ListOps.Length(Range(1, 4))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void LengthOfLargeList() { - Assert.That(ListOps.Length(Range(1, Big)), Is.EqualTo(Big)); + Assert.Equal(Big, ListOps.Length(Range(1, Big))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void ReverseOfEmptylist() { - Assert.That(ListOps.Reverse(EmptyList), Is.EquivalentTo(EmptyList)); + Assert.Equal(EmptyList, ListOps.Reverse(EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void ReverseOfNonEmptyList() { - Assert.That(ListOps.Reverse(Range(1, 100)), Is.EquivalentTo(Range(1, 100).OrderByDescending(x => x).ToList())); + Assert.Equal(Range(1, 100).OrderByDescending(x => x).ToList(), ListOps.Reverse(Range(1, 100))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void MapOfEmptylist() { - Assert.That(ListOps.Map(x => x + 1, EmptyList), Is.EquivalentTo(EmptyList)); + Assert.Equal(EmptyList, ListOps.Map(x => x + 1, EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void MapOfNonEmptyList() { - Assert.That(ListOps.Map(x => x + 1, new List {1, 3, 5, 7}), Is.EquivalentTo(new List {2, 4, 6, 8})); + Assert.Equal(new List {2, 4, 6, 8}, ListOps.Map(x => x + 1, new List {1, 3, 5, 7})); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FilterOfEmptylist() { - Assert.That(ListOps.Filter(x => true, EmptyList), Is.EquivalentTo(EmptyList)); + Assert.Equal(EmptyList, ListOps.Filter(x => true, EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FilterOfNormalList() { - Assert.That(ListOps.Filter(Odd, Range(1, 4)), Is.EquivalentTo(new List {1, 3})); + Assert.Equal(new List {1, 3}, ListOps.Filter(Odd, Range(1, 4))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldlOfEmptylist() { - Assert.That(ListOps.Foldl((acc, x) => acc + x, 0, EmptyList), Is.EqualTo(0)); + Assert.Equal(0, ListOps.Foldl((acc, x) => acc + x, 0, EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldlOfNonEmptyList() { - Assert.That(ListOps.Foldl((acc, x) => acc + x, -3, Range(1, 4)), Is.EqualTo(7)); + Assert.Equal(7, ListOps.Foldl((acc, x) => acc + x, -3, Range(1, 4))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldlOfHugeList() { - Assert.That(ListOps.Foldl((acc, x) => acc + x, 0L, Range(1, Big)), Is.EqualTo(Big * (Big + 1L) / 2L)); + Assert.Equal(Big * (Big + 1L) / 2L, ListOps.Foldl((acc, x) => acc + x, 0L, Range(1, Big))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldlWithNonCommutativeFunction() { - Assert.That(ListOps.Foldl((acc, x) => acc - x, 10, Range(1, 4)), Is.EqualTo(0)); + Assert.Equal(0, ListOps.Foldl((acc, x) => acc - x, 10, Range(1, 4))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldlIsNotJustFoldrFlip() { - Assert.That(ListOps.Foldl((acc, x) => Cons(x, acc), EmptyList, "asdf".ToList()), Is.EqualTo("fdsa".ToList())); + Assert.Equal("fdsa", new string(ListOps.Foldl((acc, x) => Cons(x, acc), new List(), "asdf".ToList()).ToArray())); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldrAsId() { - Assert.That(ListOps.Foldr((x, acc) => Cons(x, acc), EmptyList, Range(1, Big)), Is.EquivalentTo(BigList)); + Assert.Equal(BigList, ListOps.Foldr((x, acc) => Cons(x, acc), EmptyList, Range(1, Big))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void FoldrAsAppend() { - Assert.That(ListOps.Foldr((x, acc) => Cons(x, acc), Range(100, Big), Range(1, 99)), Is.EquivalentTo(BigList)); + Assert.Equal(BigList, ListOps.Foldr((x, acc) => Cons(x, acc), Range(100, Big), Range(1, 99))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void AppendOfEmptylists() { - Assert.That(ListOps.Append(EmptyList, EmptyList), Is.EqualTo(EmptyList)); + Assert.Equal(EmptyList, ListOps.Append(EmptyList, EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void AppendOfEmptyAndNonEmptyLists() { - Assert.That(ListOps.Append(EmptyList, Range(1, 4)), Is.EqualTo(Range(1, 4))); + Assert.Equal(Range(1, 4), ListOps.Append(EmptyList, Range(1, 4))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void AppendOfNonEmptyAndEmptyLists() { - Assert.That(ListOps.Append(Range(1, 4), EmptyList), Is.EqualTo(Range(1, 4))); + Assert.Equal(Range(1, 4), ListOps.Append(Range(1, 4), EmptyList)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void AppendOfNonEmptylists() { - Assert.That(ListOps.Append(Range(1, 3), new List {4, 5}), Is.EqualTo(Range(1, 5))); + Assert.Equal(Range(1, 5), ListOps.Append(Range(1, 3), new List {4, 5})); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void AppendOfLargeLists() { - Assert.That(ListOps.Append(Range(1, Big / 2), Range(1 + Big / 2, Big)), Is.EquivalentTo(BigList)); + Assert.Equal(BigList, ListOps.Append(Range(1, Big / 2), Range(1 + Big / 2, Big))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void ConcatOfNoLists() { - Assert.That(ListOps.Concat(new List>()), Is.EqualTo(EmptyList)); + Assert.Equal(EmptyList, ListOps.Concat(new List>())); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void ConcatOfListOfLists() { - Assert.That( + Assert.Equal(Range(1, 6), ListOps.Concat(new List> { new List {1, 2}, new List {3}, EmptyList, new List {4, 5, 6} - }), Is.EqualTo(Range(1, 6))); + })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void ConcatOfLargeListOfSmallLists() { - Assert.That(ListOps.Concat(ListOps.Map(x => new List {x}, Range(1, Big))), Is.EquivalentTo(BigList)); + Assert.Equal(BigList, ListOps.Concat(ListOps.Map(x => new List {x}, Range(1, Big)))); } } \ No newline at end of file diff --git a/exercises/luhn/LuhnTest.cs b/exercises/luhn/LuhnTest.cs index f7b05b9208..a5568bb093 100644 --- a/exercises/luhn/LuhnTest.cs +++ b/exercises/luhn/LuhnTest.cs @@ -1,16 +1,16 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class LuhnTest { - [TestCase("1", ExpectedResult = false)] // single digit strings can not be valid - [TestCase("0", ExpectedResult = false, Ignore = "Remove to run test case")] // a single zero is invalid - [TestCase("046 454 286", ExpectedResult = true, Ignore = "Remove to run test case")] // valid Canadian SIN - [TestCase("046 454 287", ExpectedResult = false, Ignore = "Remove to run test case")] // invalid Canadian SIN - [TestCase("8273 1232 7352 0569", ExpectedResult = false, Ignore = "Remove to run test case")] // invalid credit card - [TestCase("827a 1232 7352 0569", ExpectedResult = false, Ignore = "Remove to run test case")] // strings that contain non-digits are not valid - public bool ValidateChecksum(string number) + [Theory] + [InlineData("1", false)] // single digit strings can not be valid + [InlineData("0", false)] // a single zero is invalid + [InlineData("046 454 286", true)] // valid Canadian SIN + [InlineData("046 454 287", false)] // invalid Canadian SIN + [InlineData("8273 1232 7352 0569", false)] // invalid credit card + [InlineData("827a 1232 7352 0569", false)] // strings that contain non-digits are not valid + public void ValidateChecksum(string number, bool expected) { - return Luhn.IsValid(number); + Assert.Equal(expected, Luhn.IsValid(number)); } } \ No newline at end of file diff --git a/exercises/markdown/MarkdownTest.cs b/exercises/markdown/MarkdownTest.cs index 9262bdabcf..6ffffb9c46 100644 --- a/exercises/markdown/MarkdownTest.cs +++ b/exercises/markdown/MarkdownTest.cs @@ -1,76 +1,76 @@ -using NUnit.Framework; +using Xunit; public class MarkdownTest { - [Test] + [Fact] public void Parses_normal_text_as_a_paragraph() { var input = "This will be a paragraph"; var expected = "

This will be a paragraph

"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Parsing_italics() { var input = "_This will be italic_"; var expected = "

This will be italic

"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Parsing_bold_text() { var input = "__This will be bold__"; var expected = "

This will be bold

"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Mixed_normal_italics_and_bold_text() { var input = "This will _be_ __mixed__"; var expected = "

This will be mixed

"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void With_h1_header_level() { var input = "# This will be an h1"; var expected = "

This will be an h1

"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void With_h2_header_level() { var input = "## This will be an h2"; var expected = "

This will be an h2

"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void With_h6_header_level() { var input = "###### This will be an h6"; var expected = "
This will be an h6
"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Unordered_lists() { var input = "* Item 1\n* Item 2"; var expected = "
  • Item 1
  • Item 2
"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } - [Test] + [Fact(Skip = "Remove to run test")] public void With_a_little_bit_of_everything() { var input = "# Header!\n* __Bold Item__\n* _Italic Item_"; var expected = "

Header!

  • Bold Item
  • Italic Item
"; - Assert.That(Markdown.Parse(input), Is.EqualTo(expected)); + Assert.Equal(expected, Markdown.Parse(input)); } } \ No newline at end of file diff --git a/exercises/matrix/MatrixTest.cs b/exercises/matrix/MatrixTest.cs index 193aa1883e..13d79af770 100644 --- a/exercises/matrix/MatrixTest.cs +++ b/exercises/matrix/MatrixTest.cs @@ -1,63 +1,69 @@ -using NUnit.Framework; +using Xunit; public class MatrixTest { - [TestCase("1", ExpectedResult = new[] { 1 })] - [TestCase("4 7", ExpectedResult = new[] { 4, 7 }, Ignore = "Remove to run test case")] - [TestCase("1 2\n10 20", ExpectedResult = new[] { 1, 2 }, Ignore = "Remove to run test case")] - [TestCase("9 7 6\n8 6 5\n5 3 2", ExpectedResult = new[] { 9, 7, 6 }, Ignore = "Remove to run test case")] - public int[] Extract_first_row(string input) + [Theory] + [InlineData("1", new[] { 1 })] + [InlineData("4 7", new[] { 4, 7 })] + [InlineData("1 2\n10 20", new[] { 1, 2 })] + [InlineData("9 7 6\n8 6 5\n5 3 2", new[] { 9, 7, 6 })] + public void Extract_first_row(string input, int[] expected) { var matrix = new Matrix(input); - return matrix.Row(0); + Assert.Equal(expected, matrix.Row(0)); } - [TestCase("5", ExpectedResult = new[] { 5 }, Ignore = "Remove to run test case")] - [TestCase("9 7", ExpectedResult = new[] { 9, 7 }, Ignore = "Remove to run test case")] - [TestCase("9 8 7\n19 18 17", ExpectedResult = new[] { 19, 18, 17 }, Ignore = "Remove to run test case")] - [TestCase("1 4 9\n16 25 36\n5 6 7", ExpectedResult = new[] { 5, 6, 7 }, Ignore = "Remove to run test case")] - public int[] Extract_last_row(string input) + [Theory(Skip = "Remove to run test")] + [InlineData("5", new[] { 5 })] + [InlineData("9 7", new[] { 9, 7 })] + [InlineData("9 8 7\n19 18 17", new[] { 19, 18, 17 })] + [InlineData("1 4 9\n16 25 36\n5 6 7", new[] { 5, 6, 7 })] + public void Extract_last_row(string input, int[] expected) { var matrix = new Matrix(input); - return matrix.Row(matrix.Rows - 1); + Assert.Equal(expected, matrix.Row(matrix.Rows - 1)); } - [TestCase("55 44", ExpectedResult = new[] { 55 }, Ignore = "Remove to run test case")] - [TestCase("89 1903\n18 3", ExpectedResult = new[] { 89, 18 }, Ignore = "Remove to run test case")] - [TestCase("1 2 3\n4 5 6\n7 8 9\n8 7 6", ExpectedResult = new[] { 1, 4, 7, 8 }, Ignore = "Remove to run test case")] - public int[] Extract_first_column(string input) + [Theory(Skip = "Remove to run test")] + [InlineData("55 44", new[] { 55 })] + [InlineData("89 1903\n18 3", new[] { 89, 18 })] + [InlineData("1 2 3\n4 5 6\n7 8 9\n8 7 6", new[] { 1, 4, 7, 8 })] + public void Extract_first_column(string input, int[] expected) { var matrix = new Matrix(input); - return matrix.Col(0); + Assert.Equal(expected, matrix.Col(0)); } - [TestCase("28", ExpectedResult = new[] { 28 }, Ignore = "Remove to run test case")] - [TestCase("13\n16\n19", ExpectedResult = new[] { 13, 16, 19 }, Ignore = "Remove to run test case")] - [TestCase("289 21903 23\n218 23 21", ExpectedResult = new[] { 23, 21 }, Ignore = "Remove to run test case")] - [TestCase("11 12 13\n14 15 16\n17 18 19\n18 17 16", ExpectedResult = new[] { 13, 16, 19, 16 }, Ignore = "Remove to run test case")] - public int[] Extract_last_column(string input) + [Theory(Skip = "Remove to run test")] + [InlineData("28", new[] { 28 })] + [InlineData("13\n16\n19", new[] { 13, 16, 19 })] + [InlineData("289 21903 23\n218 23 21", new[] { 23, 21 })] + [InlineData("11 12 13\n14 15 16\n17 18 19\n18 17 16", new[] { 13, 16, 19, 16 })] + public void Extract_last_column(string input, int[] expected) { var matrix = new Matrix(input); - return matrix.Col(matrix.Cols - 1); + Assert.Equal(expected, matrix.Col(matrix.Cols - 1)); } - [TestCase("28", ExpectedResult = 1, Ignore = "Remove to run test case")] - [TestCase("13\n16", ExpectedResult = 2, Ignore = "Remove to run test case")] - [TestCase("289 21903\n23 218\n23 21", ExpectedResult = 3, Ignore = "Remove to run test case")] - [TestCase("11 12 13\n14 15 16\n17 18 19\n18 17 16", ExpectedResult = 4, Ignore = "Remove to run test case")] - public int Number_of_rows(string input) + [Theory(Skip = "Remove to run test")] + [InlineData("28", 1)] + [InlineData("13\n16", 2)] + [InlineData("289 21903\n23 218\n23 21", 3)] + [InlineData("11 12 13\n14 15 16\n17 18 19\n18 17 16", 4)] + public void Number_of_rows(string input, int expected) { var matrix = new Matrix(input); - return matrix.Rows; + Assert.Equal(expected, matrix.Rows); } - [TestCase("28", ExpectedResult = 1, Ignore = "Remove to run test case")] - [TestCase("13 2\n16 3\n19 4", ExpectedResult = 2, Ignore = "Remove to run test case")] - [TestCase("289 21903\n23 218\n23 21", ExpectedResult = 2, Ignore = "Remove to run test case")] - [TestCase("11 12 13\n14 15 16\n17 18 19\n18 17 16", ExpectedResult = 3, Ignore = "Remove to run test case")] - public int Number_of_columns(string input) + [Theory(Skip = "Remove to run test")] + [InlineData("28", 1)] + [InlineData("13 2\n16 3\n19 4", 2)] + [InlineData("289 21903\n23 218\n23 21", 2)] + [InlineData("11 12 13\n14 15 16\n17 18 19\n18 17 16", 3)] + public void Number_of_columns(string input, int expected) { var matrix = new Matrix(input); - return matrix.Cols; + Assert.Equal(expected, matrix.Cols); } } \ No newline at end of file diff --git a/exercises/meetup/MeetupTest.cs b/exercises/meetup/MeetupTest.cs index 0bbad6055a..5b1ea909f8 100644 --- a/exercises/meetup/MeetupTest.cs +++ b/exercises/meetup/MeetupTest.cs @@ -1,89 +1,89 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class MeetupTest { - [TestCase(5, DayOfWeek.Monday, ExpectedResult = "2013-5-13")] - [TestCase(3, DayOfWeek.Tuesday, ExpectedResult = "2013-3-19")] - [TestCase(1, DayOfWeek.Wednesday, ExpectedResult = "2013-1-16")] - [TestCase(5, DayOfWeek.Thursday, ExpectedResult = "2013-5-16")] - [TestCase(4, DayOfWeek.Friday, ExpectedResult = "2013-4-19")] - [TestCase(2, DayOfWeek.Saturday, ExpectedResult = "2013-2-16")] - [TestCase(10, DayOfWeek.Sunday, ExpectedResult = "2013-10-13")] - public string Finds_first_teenth_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek) + [Theory] + [InlineData(5, DayOfWeek.Monday, "2013-5-13")] + [InlineData(3, DayOfWeek.Tuesday, "2013-3-19")] + [InlineData(1, DayOfWeek.Wednesday, "2013-1-16")] + [InlineData(5, DayOfWeek.Thursday, "2013-5-16")] + [InlineData(4, DayOfWeek.Friday, "2013-4-19")] + [InlineData(2, DayOfWeek.Saturday, "2013-2-16")] + [InlineData(10, DayOfWeek.Sunday, "2013-10-13")] + public void Finds_first_teenth_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek, string expected) { DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Teenth); - return day.ToString("yyyy-M-d"); + Assert.Equal(expected, day.ToString("yyyy-M-d")); } - [Ignore("Remove to run test")] - [TestCase(3, DayOfWeek.Monday, ExpectedResult = "2013-3-4")] - [TestCase(5, DayOfWeek.Tuesday, ExpectedResult = "2013-5-7")] - [TestCase(7, DayOfWeek.Wednesday, ExpectedResult = "2013-7-3")] - [TestCase(9, DayOfWeek.Thursday, ExpectedResult = "2013-9-5")] - [TestCase(11, DayOfWeek.Friday, ExpectedResult = "2013-11-1")] - [TestCase(1, DayOfWeek.Saturday, ExpectedResult = "2013-1-5")] - [TestCase(4, DayOfWeek.Sunday, ExpectedResult = "2013-4-7")] - public string Finds_first_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek) + [Theory(Skip = "Remove to run test")] + [InlineData(3, DayOfWeek.Monday, "2013-3-4")] + [InlineData(5, DayOfWeek.Tuesday, "2013-5-7")] + [InlineData(7, DayOfWeek.Wednesday, "2013-7-3")] + [InlineData(9, DayOfWeek.Thursday, "2013-9-5")] + [InlineData(11, DayOfWeek.Friday, "2013-11-1")] + [InlineData(1, DayOfWeek.Saturday, "2013-1-5")] + [InlineData(4, DayOfWeek.Sunday, "2013-4-7")] + public void Finds_first_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek, string expected) { DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.First); - return day.ToString("yyyy-M-d"); + Assert.Equal(expected, day.ToString("yyyy-M-d")); } - [Ignore("Remove to run test")] - [TestCase(3, DayOfWeek.Monday, ExpectedResult = "2013-3-11")] - [TestCase(5, DayOfWeek.Tuesday, ExpectedResult = "2013-5-14")] - [TestCase(7, DayOfWeek.Wednesday, ExpectedResult = "2013-7-10")] - [TestCase(9, DayOfWeek.Thursday, ExpectedResult = "2013-9-12")] - [TestCase(12, DayOfWeek.Friday, ExpectedResult = "2013-12-13")] - [TestCase(2, DayOfWeek.Saturday, ExpectedResult = "2013-2-9")] - [TestCase(4, DayOfWeek.Sunday, ExpectedResult = "2013-4-14")] - public string Finds_second_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek) + [Theory(Skip = "Remove to run test")] + [InlineData(3, DayOfWeek.Monday, "2013-3-11")] + [InlineData(5, DayOfWeek.Tuesday, "2013-5-14")] + [InlineData(7, DayOfWeek.Wednesday, "2013-7-10")] + [InlineData(9, DayOfWeek.Thursday, "2013-9-12")] + [InlineData(12, DayOfWeek.Friday, "2013-12-13")] + [InlineData(2, DayOfWeek.Saturday, "2013-2-9")] + [InlineData(4, DayOfWeek.Sunday, "2013-4-14")] + public void Finds_second_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek, string expected) { DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Second); - return day.ToString("yyyy-M-d"); + Assert.Equal(expected, day.ToString("yyyy-M-d")); } - [Ignore("Remove to run test")] - [TestCase(3, DayOfWeek.Monday, ExpectedResult = "2013-3-18")] - [TestCase(5, DayOfWeek.Tuesday, ExpectedResult = "2013-5-21")] - [TestCase(7, DayOfWeek.Wednesday, ExpectedResult = "2013-7-17")] - [TestCase(9, DayOfWeek.Thursday, ExpectedResult = "2013-9-19")] - [TestCase(12, DayOfWeek.Friday, ExpectedResult = "2013-12-20")] - [TestCase(2, DayOfWeek.Saturday, ExpectedResult = "2013-2-16")] - [TestCase(4, DayOfWeek.Sunday, ExpectedResult = "2013-4-21")] - public string Finds_third_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek) + [Theory(Skip = "Remove to run test")] + [InlineData(3, DayOfWeek.Monday, "2013-3-18")] + [InlineData(5, DayOfWeek.Tuesday, "2013-5-21")] + [InlineData(7, DayOfWeek.Wednesday, "2013-7-17")] + [InlineData(9, DayOfWeek.Thursday, "2013-9-19")] + [InlineData(12, DayOfWeek.Friday, "2013-12-20")] + [InlineData(2, DayOfWeek.Saturday, "2013-2-16")] + [InlineData(4, DayOfWeek.Sunday, "2013-4-21")] + public void Finds_third_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek, string expected) { DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Third); - return day.ToString("yyyy-M-d"); + Assert.Equal(expected, day.ToString("yyyy-M-d")); } - [Ignore("Remove to run test")] - [TestCase(3, DayOfWeek.Monday, ExpectedResult = "2013-3-25")] - [TestCase(5, DayOfWeek.Tuesday, ExpectedResult = "2013-5-28")] - [TestCase(7, DayOfWeek.Wednesday, ExpectedResult = "2013-7-24")] - [TestCase(9, DayOfWeek.Thursday, ExpectedResult = "2013-9-26")] - [TestCase(12, DayOfWeek.Friday, ExpectedResult = "2013-12-27")] - [TestCase(2, DayOfWeek.Saturday, ExpectedResult = "2013-2-23")] - [TestCase(4, DayOfWeek.Sunday, ExpectedResult = "2013-4-28")] - public string Finds_fourth_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek) + [Theory(Skip = "Remove to run test")] + [InlineData(3, DayOfWeek.Monday, "2013-3-25")] + [InlineData(5, DayOfWeek.Tuesday, "2013-5-28")] + [InlineData(7, DayOfWeek.Wednesday, "2013-7-24")] + [InlineData(9, DayOfWeek.Thursday, "2013-9-26")] + [InlineData(12, DayOfWeek.Friday, "2013-12-27")] + [InlineData(2, DayOfWeek.Saturday, "2013-2-23")] + [InlineData(4, DayOfWeek.Sunday, "2013-4-28")] + public void Finds_fourth_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek, string expected) { DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Fourth); - return day.ToString("yyyy-M-d"); + Assert.Equal(expected, day.ToString("yyyy-M-d")); } - [Ignore("Remove to run test")] - [TestCase(3, DayOfWeek.Monday, ExpectedResult = "2013-3-25")] - [TestCase(5, DayOfWeek.Tuesday, ExpectedResult = "2013-5-28")] - [TestCase(7, DayOfWeek.Wednesday, ExpectedResult = "2013-7-31")] - [TestCase(9, DayOfWeek.Thursday, ExpectedResult = "2013-9-26")] - [TestCase(12, DayOfWeek.Friday, ExpectedResult = "2013-12-27")] - [TestCase(2, DayOfWeek.Saturday, ExpectedResult = "2013-2-23")] - [TestCase(3, DayOfWeek.Sunday, ExpectedResult = "2013-3-31")] - public string Finds_last_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek) + [Theory(Skip = "Remove to run test")] + [InlineData(3, DayOfWeek.Monday, "2013-3-25")] + [InlineData(5, DayOfWeek.Tuesday, "2013-5-28")] + [InlineData(7, DayOfWeek.Wednesday, "2013-7-31")] + [InlineData(9, DayOfWeek.Thursday, "2013-9-26")] + [InlineData(12, DayOfWeek.Friday, "2013-12-27")] + [InlineData(2, DayOfWeek.Saturday, "2013-2-23")] + [InlineData(3, DayOfWeek.Sunday, "2013-3-31")] + public void Finds_last_day_of_week_in_a_month(int month, DayOfWeek dayOfWeek, string expected) { DateTime day = new Meetup(month, 2013).Day(dayOfWeek, Schedule.Last); - return day.ToString("yyyy-M-d"); + Assert.Equal(expected, day.ToString("yyyy-M-d")); } } \ No newline at end of file diff --git a/exercises/minesweeper/MinesweeperTest.cs b/exercises/minesweeper/MinesweeperTest.cs index bcd95b1312..8d76497689 100644 --- a/exercises/minesweeper/MinesweeperTest.cs +++ b/exercises/minesweeper/MinesweeperTest.cs @@ -1,19 +1,17 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class MinesweeperTest { - [Test] + [Fact] public void Zero_sized_board() { var input = ""; var expected = ""; - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_board() { var input = FormatInput(new[] @@ -30,11 +28,10 @@ public void Empty_board() " " }); - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Board_full_of_mines() { var input = FormatInput(new[] @@ -51,11 +48,10 @@ public void Board_full_of_mines() "***" }); - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Surrounded() { var input = FormatInput(new[] @@ -72,11 +68,10 @@ public void Surrounded() "***" }); - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Horizontal_line() { var input = FormatInput(new[] @@ -89,11 +84,10 @@ public void Horizontal_line() "1*2*1" }); - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Vertical_line() { var input = FormatInput(new[] @@ -114,11 +108,10 @@ public void Vertical_line() "1" }); - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cross() { var input = FormatInput(new[] @@ -139,7 +132,7 @@ public void Cross() " 2*2 " }); - Assert.That(Minesweeper.Annotate(input), Is.EqualTo(expected)); + Assert.Equal(expected, Minesweeper.Annotate(input)); } private string FormatInput(string[] input) diff --git a/exercises/nth-prime/NthPrimeTest.cs b/exercises/nth-prime/NthPrimeTest.cs index 4e214f1a54..bbb33a6955 100644 --- a/exercises/nth-prime/NthPrimeTest.cs +++ b/exercises/nth-prime/NthPrimeTest.cs @@ -1,20 +1,21 @@ -using NUnit.Framework; +using Xunit; public class NthPrimeTest { - [TestCase(1, ExpectedResult = 2)] - [TestCase(2, ExpectedResult = 3, Ignore = "Remove to run test case")] - [TestCase(3, ExpectedResult = 5, Ignore = "Remove to run test case")] - [TestCase(4, ExpectedResult = 7, Ignore = "Remove to run test case")] - [TestCase(5, ExpectedResult = 11, Ignore = "Remove to run test case")] - [TestCase(6, ExpectedResult = 13, Ignore = "Remove to run test case")] - [TestCase(7, ExpectedResult = 17, Ignore = "Remove to run test case")] - [TestCase(8, ExpectedResult = 19, Ignore = "Remove to run test case")] - [TestCase(1000, ExpectedResult = 7919, Ignore = "Remove to run test case")] - [TestCase(10000, ExpectedResult = 104729, Ignore = "Remove to run test case")] - [TestCase(10001, ExpectedResult = 104743, Ignore = "Remove to run test case")] - public int Nth_prime_calculated(int nth) + [Theory] + [InlineData(1, 2)] + [InlineData(2, 3)] + [InlineData(3, 5)] + [InlineData(4, 7)] + [InlineData(5, 11)] + [InlineData(6, 13)] + [InlineData(7, 17)] + [InlineData(8, 19)] + [InlineData(1000, 7919)] + [InlineData(10000, 104729)] + [InlineData(10001, 104743)] + public void Nth_prime_calculated(int nth, int expected) { - return NthPrime.Nth(nth); + Assert.Equal(expected, NthPrime.Nth(nth)); } } \ No newline at end of file diff --git a/exercises/nucleotide-count/NucleotideCountTest.cs b/exercises/nucleotide-count/NucleotideCountTest.cs index b66b6b953a..71ce18f736 100644 --- a/exercises/nucleotide-count/NucleotideCountTest.cs +++ b/exercises/nucleotide-count/NucleotideCountTest.cs @@ -1,73 +1,65 @@ using System.Collections.Generic; -using NUnit.Framework; +using Xunit; -[TestFixture] public class NucleoTideCountTest { - [Test] + [Fact] public void Has_no_nucleotides() { var dna = new DNA(""); var expected = new Dictionary { { 'A', 0 }, { 'T', 0 }, { 'C', 0 }, { 'G', 0 } }; - Assert.That(dna.NucleotideCounts, Is.EqualTo(expected)); + Assert.Equal(expected, dna.NucleotideCounts); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Has_no_adenosine() { var dna = new DNA(""); - Assert.That(dna.Count('A'), Is.EqualTo(0)); + Assert.Equal(0, dna.Count('A')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Repetitive_cytidine_gets_counts() { var dna = new DNA("CCCCC"); - Assert.That(dna.Count('C'), Is.EqualTo(5)); + Assert.Equal(5, dna.Count('C')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Repetitive_sequence_has_only_guanosine() { var dna = new DNA("GGGGGGGG"); var expected = new Dictionary { { 'A', 0 }, { 'T', 0 }, { 'C', 0 }, { 'G', 8 } }; - Assert.That(dna.NucleotideCounts, Is.EqualTo(expected)); + Assert.Equal(expected, dna.NucleotideCounts); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Counts_only_thymidine() { var dna = new DNA("GGGGTAACCCGG"); - Assert.That(dna.Count('T'), Is.EqualTo(1)); + Assert.Equal(1, dna.Count('T')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Counts_a_nucleotide_only_once() { var dna = new DNA("GGTTGG"); dna.Count('T'); - Assert.That(dna.Count('T'), Is.EqualTo(2)); + Assert.Equal(2, dna.Count('T')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Validates_nucleotides() { var dna = new DNA("GGTTGG"); Assert.Throws(() => dna.Count('X')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Counts_all_nucleotides() { var dna = new DNA("AGCTTTTCATTCTGACTGCAACGGGCAATATGTCTCTGTGTGGATTAAAAAAAGAGTGTCTGATAGCAGC"); var expected = new Dictionary { { 'A', 20 }, { 'T', 21 }, { 'C', 12 }, { 'G', 17 } }; - Assert.That(dna.NucleotideCounts, Is.EqualTo(expected)); + Assert.Equal(expected, dna.NucleotideCounts); } } diff --git a/exercises/ocr-numbers/OcrNumbersTest.cs b/exercises/ocr-numbers/OcrNumbersTest.cs index 4f0bedd4df..723ccf9d7f 100644 --- a/exercises/ocr-numbers/OcrNumbersTest.cs +++ b/exercises/ocr-numbers/OcrNumbersTest.cs @@ -1,168 +1,154 @@ -using NUnit.Framework; +using Xunit; public class OcrNumbersTest { - [Test] + [Fact] public void Recognizes_zero() { var converted = OcrNumbers.Convert(" _ " + "\n" + "| |" + "\n" + "|_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("0")); + Assert.Equal("0", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_one() { var converted = OcrNumbers.Convert(" " + "\n" + " |" + "\n" + " |" + "\n" + " "); - Assert.That(converted, Is.EqualTo("1")); + Assert.Equal("1", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_two() { var converted = OcrNumbers.Convert(" _ " + "\n" + " _|" + "\n" + "|_ " + "\n" + " "); - Assert.That(converted, Is.EqualTo("2")); + Assert.Equal("2", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_three() { var converted = OcrNumbers.Convert(" _ " + "\n" + " _|" + "\n" + " _|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("3")); + Assert.Equal("3", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_four() { var converted = OcrNumbers.Convert(" " + "\n" + "|_|" + "\n" + " |" + "\n" + " "); - Assert.That(converted, Is.EqualTo("4")); + Assert.Equal("4", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_five() { var converted = OcrNumbers.Convert(" _ " + "\n" + "|_ " + "\n" + " _|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("5")); + Assert.Equal("5", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_six() { var converted = OcrNumbers.Convert(" _ " + "\n" + "|_ " + "\n" + "|_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("6")); + Assert.Equal("6", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_seven() { var converted = OcrNumbers.Convert(" _ " + "\n" + " |" + "\n" + " |" + "\n" + " "); - Assert.That(converted, Is.EqualTo("7")); + Assert.Equal("7", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_eight() { var converted = OcrNumbers.Convert(" _ " + "\n" + "|_|" + "\n" + "|_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("8")); + Assert.Equal("8", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_nine() { var converted = OcrNumbers.Convert(" _ " + "\n" + "|_|" + "\n" + " _|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("9")); + Assert.Equal("9", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_garble() { var converted = OcrNumbers.Convert(" " + "\n" + "| |" + "\n" + "| |" + "\n" + " "); - Assert.That(converted, Is.EqualTo("?")); + Assert.Equal("?", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_ten() { var converted = OcrNumbers.Convert(" _ " + "\n" + " || |" + "\n" + " ||_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("10")); + Assert.Equal("10", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_110101100() { var converted = OcrNumbers.Convert(" _ _ _ _ " + "\n" + " | || | || | | || || |" + "\n" + " | ||_| ||_| | ||_||_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("110101100")); + Assert.Equal("110101100", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_numbers_and_garble() { var converted = OcrNumbers.Convert(" _ _ _ " + "\n" + " | || | || | || || |" + "\n" + " | | _| ||_| | ||_||_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("11?10?1?0")); + Assert.Equal("11?10?1?0", converted); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recognizes_1234567890() { var converted = OcrNumbers.Convert(" _ _ _ _ _ _ _ _ " + "\n" + " | _| _||_||_ |_ ||_||_|| |" + "\n" + " ||_ _| | _||_| ||_| _||_|" + "\n" + " "); - Assert.That(converted, Is.EqualTo("1234567890")); + Assert.Equal("1234567890", converted); } } \ No newline at end of file diff --git a/exercises/paket.references b/exercises/paket.references index 8a39542b97..38898a345b 100644 --- a/exercises/paket.references +++ b/exercises/paket.references @@ -1,2 +1,2 @@ -NUnit -Sprache \ No newline at end of file +Sprache +xunit \ No newline at end of file diff --git a/exercises/palindrome-products/PalindromeTest.cs b/exercises/palindrome-products/PalindromeTest.cs index f7668cf3b6..8e14284fba 100644 --- a/exercises/palindrome-products/PalindromeTest.cs +++ b/exercises/palindrome-products/PalindromeTest.cs @@ -1,76 +1,69 @@ using System; -using NUnit.Framework; +using Xunit; public class PalindromeTest { - [Test] + [Fact] public void Largest_palindrome_from_single_digit_factors() { var actual = Palindrome.Largest(9); - Assert.That(actual.Value, Is.EqualTo(9)); - Assert.That(actual.Factors, Is.EqualTo(new [] { Tuple.Create(1, 9), Tuple.Create(3, 3) })); + Assert.Equal(9, actual.Value); + Assert.Equal(new [] { Tuple.Create(1, 9), Tuple.Create(3, 3) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Smallest_palindrome_from_single_digit_factors() { var actual = Palindrome.Smallest(9); - Assert.That(actual.Value, Is.EqualTo(1)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(1, 1) })); + Assert.Equal(1, actual.Value); + Assert.Equal(new[] { Tuple.Create(1, 1) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Largest_palindrome_from_double_digit_actors() { var actual = Palindrome.Largest(10, 99); - Assert.That(actual.Value, Is.EqualTo(9009)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(91, 99) })); + Assert.Equal(9009, actual.Value); + Assert.Equal(new[] { Tuple.Create(91, 99) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Smallest_palindrome_from_double_digit_factors() { var actual = Palindrome.Smallest(10, 99); - Assert.That(actual.Value, Is.EqualTo(121)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(11, 11) })); + Assert.Equal(121, actual.Value); + Assert.Equal(new[] { Tuple.Create(11, 11) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Largest_palindrome_from_triple_digit_factors() { var actual = Palindrome.Largest(100, 999); - Assert.That(actual.Value, Is.EqualTo(906609)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(913, 993) })); + Assert.Equal(906609, actual.Value); + Assert.Equal(new[] { Tuple.Create(913, 993) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Smallest_palindrome_from_triple_digit_factors() { var actual = Palindrome.Smallest(100, 999); - Assert.That(actual.Value, Is.EqualTo(10201)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(101, 101) })); + Assert.Equal(10201, actual.Value); + Assert.Equal(new[] { Tuple.Create(101, 101) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Largest_palindrome_from_four_digit_factors() { var actual = Palindrome.Largest(1000, 9999); - Assert.That(actual.Value, Is.EqualTo(99000099)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(9901, 9999) })); + Assert.Equal(99000099, actual.Value); + Assert.Equal(new[] { Tuple.Create(9901, 9999) }, actual.Factors); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Smallest_palindrome_from_four_digit_factors() { var actual = Palindrome.Smallest(1000, 9999); - Assert.That(actual.Value, Is.EqualTo(1002001)); - Assert.That(actual.Factors, Is.EqualTo(new[] { Tuple.Create(1001, 1001) })); + Assert.Equal(1002001, actual.Value); + Assert.Equal(new[] { Tuple.Create(1001, 1001) }, actual.Factors); } } \ No newline at end of file diff --git a/exercises/pangram/PangramTest.cs b/exercises/pangram/PangramTest.cs index 9397714651..733157b617 100644 --- a/exercises/pangram/PangramTest.cs +++ b/exercises/pangram/PangramTest.cs @@ -1,84 +1,74 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class PangramTest { - [Test] + [Fact] public void Empty_sentence() { var input = ""; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(false)); + Assert.Equal(false, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pangram_with_only_lower_case() { var input = "the quick brown fox jumps over the lazy dog"; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(true)); + Assert.Equal(true, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Missing_character_x() { var input = "a quick movement of the enemy will jeopardize five gunboats"; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(false)); + Assert.Equal(false, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Another_missing_character_x() { var input = "the quick brown fish jumps over the lazy dog"; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(false)); + Assert.Equal(false, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pangram_with_underscores() { var input = "the_quick_brown_fox_jumps_over_the_lazy_dog"; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(true)); + Assert.Equal(true, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pangram_with_numbers() { var input = "the 1 quick brown fox jumps over the 2 lazy dogs"; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(true)); + Assert.Equal(true, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Missing_letters_replaced_by_numbers() { var input = "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog"; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(false)); + Assert.Equal(false, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pangram_with_mixed_case_and_punctuation() { var input = "\"Five quacking Zephyrs jolt my wax bed.\""; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(true)); + Assert.Equal(true, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pangram_with_non_ascii_characters() { var input = "Victor jagt zwölf Boxkämpfer quer über den großen Sylter Deich."; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(true)); + Assert.Equal(true, Pangram.IsPangram(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pangram_in_alphabet_other_than_ascii() { var input = "Широкая электрификация южных губерний даст мощный толчок подъёму сельского хозяйства."; - Assert.That(Pangram.IsPangram(input), Is.EqualTo(false)); + Assert.Equal(false, Pangram.IsPangram(input)); } } \ No newline at end of file diff --git a/exercises/parallel-letter-frequency/ParallelLetterFrequencyTest.cs b/exercises/parallel-letter-frequency/ParallelLetterFrequencyTest.cs index 42237b1740..cc91d05a4d 100644 --- a/exercises/parallel-letter-frequency/ParallelLetterFrequencyTest.cs +++ b/exercises/parallel-letter-frequency/ParallelLetterFrequencyTest.cs @@ -1,6 +1,6 @@ using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; public class ParallelLetterParallelLetterFrequency { @@ -37,17 +37,16 @@ public class ParallelLetterParallelLetterFrequency "O say does that star-spangled banner yet wave,\n" + "O'er the land of the free and the home of the brave?\n"; - [Test] + [Fact] public void No_texts_mean_no_letters() { var input = Enumerable.Empty(); var actual = ParallelLetterFrequency.Calculate(input); var expected = new Dictionary(); - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_letter() { var input = new[] { "a" }; @@ -56,11 +55,10 @@ public void One_letter() { { 'a', 1 } }; - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Case_insensitivity() { var input = new[] { "aA" }; @@ -69,21 +67,19 @@ public void Case_insensitivity() { { 'a', 2 } }; - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Many_empty_texts_still_mean_no_letters() { var input = Enumerable.Repeat(" ", 10000); var actual = ParallelLetterFrequency.Calculate(input); var expected = new Dictionary(); - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Many_times_the_same_text_gives_a_predictable_result() { var input = Enumerable.Repeat("abc", 1000); @@ -94,11 +90,10 @@ public void Many_times_the_same_text_gives_a_predictable_result() { 'b', 1000 }, { 'c', 1000 } }; - Assert.That(actual, Is.EquivalentTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Punctuation_doesnt_count() { var input = new[] { OdeAnDieFreude }; @@ -106,8 +101,7 @@ public void Punctuation_doesnt_count() Assert.False(actual.ContainsKey(',')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Numbers_dont_count() { var input = new[] { "Testing, 1, 2, 3" }; @@ -115,14 +109,13 @@ public void Numbers_dont_count() Assert.False(actual.ContainsKey('1')); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void All_three_anthems_together() { var input = new[] { OdeAnDieFreude, Wilhelmus, StarSpangledBanner }; var actual = ParallelLetterFrequency.Calculate(input); - Assert.That(actual['a'], Is.EqualTo(49)); - Assert.That(actual['t'], Is.EqualTo(56)); - Assert.That(actual['ü'], Is.EqualTo(2)); + Assert.Equal(49, actual['a']); + Assert.Equal(56, actual['t']); + Assert.Equal(2, actual['ü']); } } \ No newline at end of file diff --git a/exercises/pascals-triangle/PascalsTriangleTest.cs b/exercises/pascals-triangle/PascalsTriangleTest.cs index ebc1950188..216e859b92 100644 --- a/exercises/pascals-triangle/PascalsTriangleTest.cs +++ b/exercises/pascals-triangle/PascalsTriangleTest.cs @@ -1,52 +1,80 @@ -using System.Linq; -using NUnit.Framework; +using System; +using System.Collections.Generic; +using System.Linq; +using Xunit; public class PascalsTriangleTest { - [Test] + [Fact] public void One_row() { var actual = PascalsTriangle.Calculate(1); - Assert.That(actual, Is.EqualTo(new[] { new[] { 1 } })); + var expected = new[] { new[] { 1 } }; + Assert.Equal(expected, actual, NestedEnumerableEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_rows() { - var actual = PascalsTriangle.Calculate(2); - Assert.That(actual, Is.EqualTo(new[] { new[] { 1 }, new[] { 1, 1 } })); + var actual = PascalsTriangle.Calculate(2).ToArray(); + var expected = new[] { new[] { 1 }, new[] { 1, 1 } }; + Assert.Equal(expected, actual, NestedEnumerableEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Three_rows() { var actual = PascalsTriangle.Calculate(3); - Assert.That(actual, Is.EqualTo(new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 } })); + var expected = new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 } }; + Assert.Equal(expected, actual, NestedEnumerableEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Four_rows() { var actual = PascalsTriangle.Calculate(4); - Assert.That(actual, Is.EqualTo(new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 }, new[] { 1, 3, 3, 1 } })); + var expected = new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 }, new[] { 1, 3, 3, 1 } }; + Assert.Equal(expected, actual, NestedEnumerableEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Five_rows() { var actual = PascalsTriangle.Calculate(5); - Assert.That(actual, Is.EqualTo(new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 }, new[] { 1, 3, 3, 1 }, new [] { 1, 4, 6, 4, 1 } })); + var expected = new[] { new[] { 1 }, new[] { 1, 1 }, new[] { 1, 2, 1 }, new[] { 1, 3, 3, 1 }, new[] { 1, 4, 6, 4, 1 } }; + Assert.Equal(expected, actual, NestedEnumerableEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Twenty_rows() { var actual = PascalsTriangle.Calculate(20).Last(); - Assert.That(actual, Is.EqualTo(new[] { 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 })); + var expected = new[] { 1, 19, 171, 969, 3876, 11628, 27132, 50388, 75582, 92378, 92378, 75582, 50388, 27132, 11628, 3876, 969, 171, 19, 1 }; + Assert.Equal(expected, actual); + } + + private class EnumerableEqualityComparer : IEqualityComparer> + { + public static readonly EnumerableEqualityComparer Instance = new EnumerableEqualityComparer(); + + public bool Equals(IEnumerable x, IEnumerable y) => x.SequenceEqual(y); + + public int GetHashCode(IEnumerable obj) + { + throw new NotImplementedException(); + } + } + + private class NestedEnumerableEqualityComparer : IEqualityComparer>> + { + public static readonly NestedEnumerableEqualityComparer Instance = new NestedEnumerableEqualityComparer(); + + public bool Equals(IEnumerable> x, IEnumerable> y) + => x.SequenceEqual(y, EnumerableEqualityComparer.Instance); + + public int GetHashCode(IEnumerable> obj) + { + throw new NotImplementedException(); + } } } \ No newline at end of file diff --git a/exercises/perfect-numbers/PerfectNumbersTest.cs b/exercises/perfect-numbers/PerfectNumbersTest.cs index 5aaf6a6056..3e458bec23 100644 --- a/exercises/perfect-numbers/PerfectNumbersTest.cs +++ b/exercises/perfect-numbers/PerfectNumbersTest.cs @@ -1,29 +1,31 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class PerfectNumbersTest { - [TestCase(3)] - [TestCase(7, Ignore = "Remove to run test case")] - [TestCase(13, Ignore = "Remove to run test case")] + [Theory] + [InlineData(3)] + [InlineData(7)] + [InlineData(13)] public void Can_classify_deficient_numbers(int number) { - Assert.That(PerfectNumbers.Classify(number), Is.EqualTo(NumberType.Deficient)); + Assert.Equal(NumberType.Deficient, PerfectNumbers.Classify(number)); } - [TestCase(6, Ignore = "Remove to run test case")] - [TestCase(28, Ignore = "Remove to run test case")] - [TestCase(496, Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData(6)] + [InlineData(28)] + [InlineData(496)] public void Can_classify_perfect_numbers(int number) { - Assert.That(PerfectNumbers.Classify(number), Is.EqualTo(NumberType.Perfect)); + Assert.Equal(NumberType.Perfect, PerfectNumbers.Classify(number)); } - [TestCase(12, Ignore = "Remove to run test case")] - [TestCase(18, Ignore = "Remove to run test case")] - [TestCase(20, Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData(12)] + [InlineData(18)] + [InlineData(20)] public void Can_classify_abundant_numbers(int number) { - Assert.That(PerfectNumbers.Classify(number), Is.EqualTo(NumberType.Abundant)); + Assert.Equal(NumberType.Abundant, PerfectNumbers.Classify(number)); } } \ No newline at end of file diff --git a/exercises/phone-number/PhoneNumberTest.cs b/exercises/phone-number/PhoneNumberTest.cs index 0434d8f421..258b5fe805 100644 --- a/exercises/phone-number/PhoneNumberTest.cs +++ b/exercises/phone-number/PhoneNumberTest.cs @@ -1,60 +1,53 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class PhoneNumberTest { - [Test] + [Fact] public void Cleans_parens_spaces_and_dashes() { var phone = new PhoneNumber("(123) 456-7890"); - Assert.That(phone.Number, Is.EqualTo("1234567890")); + Assert.Equal("1234567890", phone.Number); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cleans_numbers_with_dots() { var phone = new PhoneNumber("123.456.7890"); - Assert.That(phone.Number, Is.EqualTo("1234567890")); + Assert.Equal("1234567890", phone.Number); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Allows_us_country_code() { var phone = new PhoneNumber("11234567890"); - Assert.That(phone.Number, Is.EqualTo("1234567890")); + Assert.Equal("1234567890", phone.Number); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Invalid_when_11_digits() { var phone = new PhoneNumber("21234567890"); - Assert.That(phone.Number, Is.EqualTo("0000000000")); + Assert.Equal("0000000000", phone.Number); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Invalid_when_9_digits() { var phone = new PhoneNumber("123456789"); - Assert.That(phone.Number, Is.EqualTo("0000000000")); + Assert.Equal("0000000000", phone.Number); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Has_an_area_code() { var phone = new PhoneNumber("1234567890"); - Assert.That(phone.AreaCode, Is.EqualTo("123")); + Assert.Equal("123", phone.AreaCode); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Formats_a_number() { var phone = new PhoneNumber("1234567890"); - Assert.That(phone.ToString(), Is.EqualTo("(123) 456-7890")); + Assert.Equal("(123) 456-7890", phone.ToString()); } } \ No newline at end of file diff --git a/exercises/pig-latin/PigLatinTest.cs b/exercises/pig-latin/PigLatinTest.cs index 6333818199..1bc13249e8 100644 --- a/exercises/pig-latin/PigLatinTest.cs +++ b/exercises/pig-latin/PigLatinTest.cs @@ -1,88 +1,79 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class PigLatinTest { - [TestCase("apple", ExpectedResult = "appleay")] - [TestCase("ear", ExpectedResult = "earay")] - [TestCase("igloo", ExpectedResult = "iglooay")] - [TestCase("object", ExpectedResult = "objectay")] - [TestCase("under", ExpectedResult = "underay")] - public string Ay_is_added_to_words_that_start_with_vowels(string word) + [Theory] + [InlineData("apple", "appleay")] + [InlineData("ear", "earay")] + [InlineData("igloo", "iglooay")] + [InlineData("object", "objectay")] + [InlineData("under", "underay")] + public void Ay_is_added_to_words_that_start_with_vowels(string word, string expected) { - return PigLatin.Translate(word); + Assert.Equal(expected, PigLatin.Translate(word)); } - [Ignore("Remove to run test")] - [TestCase("pig", ExpectedResult = "igpay")] - [TestCase("koala", ExpectedResult = "oalakay")] - [TestCase("yellow", ExpectedResult = "ellowyay")] - [TestCase("xenon", ExpectedResult = "enonxay")] - public string First_letter_and_ay_are_moved_to_the_end_of_words_that_start_with_consonants(string word) + [Theory(Skip = "Remove to run test")] + [InlineData("pig", "igpay")] + [InlineData("koala", "oalakay")] + [InlineData("yellow", "ellowyay")] + [InlineData("xenon", "enonxay")] + public void First_letter_and_ay_are_moved_to_the_end_of_words_that_start_with_consonants(string word, string expected) { - return PigLatin.Translate(word); + Assert.Equal(expected, PigLatin.Translate(word)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Ch_is_treated_like_a_single_consonant() { - Assert.That(PigLatin.Translate("chair"), Is.EqualTo("airchay")); + Assert.Equal("airchay", PigLatin.Translate("chair")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Qu_is_treated_like_a_single_consonant() { - Assert.That(PigLatin.Translate("queen"), Is.EqualTo("eenquay")); + Assert.Equal("eenquay", PigLatin.Translate("queen")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Qu_and_a_single_preceding_consonant_are_treated_like_a_single_consonant() { - Assert.That(PigLatin.Translate("square"), Is.EqualTo("aresquay")); + Assert.Equal("aresquay", PigLatin.Translate("square")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Th_is_treated_like_a_single_consonant() { - Assert.That(PigLatin.Translate("therapy"), Is.EqualTo("erapythay")); + Assert.Equal("erapythay", PigLatin.Translate("therapy")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Thr_is_treated_like_a_single_consonant() { - Assert.That(PigLatin.Translate("thrush"), Is.EqualTo("ushthray")); + Assert.Equal("ushthray", PigLatin.Translate("thrush")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sch_is_treated_like_a_single_consonant() { - Assert.That(PigLatin.Translate("school"), Is.EqualTo("oolschay")); + Assert.Equal("oolschay", PigLatin.Translate("school")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Yt_is_treated_like_a_single_vowel() { - Assert.That(PigLatin.Translate("yttria"), Is.EqualTo("yttriaay")); + Assert.Equal("yttriaay", PigLatin.Translate("yttria")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Xr_is_treated_like_a_single_vowel() { - Assert.That(PigLatin.Translate("xray"), Is.EqualTo("xrayay")); + Assert.Equal("xrayay", PigLatin.Translate("xray")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Phrases_are_translated() { - Assert.That(PigLatin.Translate("quick fast run"), Is.EqualTo("ickquay astfay unray")); + Assert.Equal("ickquay astfay unray", PigLatin.Translate("quick fast run")); } } \ No newline at end of file diff --git a/exercises/poker/PokerTest.cs b/exercises/poker/PokerTest.cs index d39fb622d4..bb1bd2e474 100644 --- a/exercises/poker/PokerTest.cs +++ b/exercises/poker/PokerTest.cs @@ -1,181 +1,160 @@ -using NUnit.Framework; +using Xunit; public class PokerTest { - [Test] + [Fact] public void One_hand() { const string hand = "4S 5S 7H 8D JC"; - Assert.That(Poker.BestHands(new[] { hand }), Is.EqualTo(new[] { hand })); + Assert.Equal(new[] { hand }, Poker.BestHands(new[] { hand })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Nothing_vs_one_pair() { const string nothing = "4S 5H 6S 8D JH"; const string pairOf4 = "2S 4H 6S 4D JH"; - Assert.That(Poker.BestHands(new[] { nothing, pairOf4 }), Is.EqualTo(new[] { pairOf4 })); + Assert.Equal(new[] { pairOf4 }, Poker.BestHands(new[] { nothing, pairOf4 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_pairs() { const string pairOf2 = "4S 2H 6S 2D JH"; const string pairOf4 = "2S 4H 6S 4D JH"; - Assert.That(Poker.BestHands(new[] { pairOf2, pairOf4 }), Is.EqualTo(new[] { pairOf4 })); + Assert.Equal(new[] { pairOf4 }, Poker.BestHands(new[] { pairOf2, pairOf4 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_pair_vs_double_pair() { const string pairOf8 = "2S 8H 6S 8D JH"; const string doublePair = "4S 5H 4S 8D 5H"; - Assert.That(Poker.BestHands(new[] { pairOf8, doublePair }), Is.EqualTo(new[] { doublePair })); + Assert.Equal(new[] { doublePair }, Poker.BestHands(new[] { pairOf8, doublePair })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_double_pairs() { const string doublePair2And8 = "2S 8H 2S 8D JH"; const string doublePair4And5 = "4S 5H 4S 8D 5H"; - Assert.That(Poker.BestHands(new[] { doublePair2And8, doublePair4And5 }), Is.EqualTo(new[] { doublePair2And8 })); + Assert.Equal(new[] { doublePair2And8 }, Poker.BestHands(new[] { doublePair2And8, doublePair4And5 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Double_pair_vs_three() { const string doublePair2And8 = "2S 8H 2S 8D JH"; const string threeOf4 = "4S 5H 4S 8D 4H"; - Assert.That(Poker.BestHands(new[] { doublePair2And8, threeOf4 }), Is.EqualTo(new[] { threeOf4 })); + Assert.Equal(new[] { threeOf4 }, Poker.BestHands(new[] { doublePair2And8, threeOf4 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_threes() { const string threeOf2 = "2S 2H 2S 8D JH"; const string threeOf1 = "4S AH AS 8D AH"; - Assert.That(Poker.BestHands(new[] { threeOf2, threeOf1 }), Is.EqualTo(new[] { threeOf1 })); + Assert.Equal(new[] { threeOf1 }, Poker.BestHands(new[] { threeOf2, threeOf1 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Three_vs_straight() { const string threeOf4 = "4S 5H 4S 8D 4H"; const string straight = "3S 4H 2S 6D 5H"; - Assert.That(Poker.BestHands(new[] { threeOf4, straight }), Is.EqualTo(new[] { straight })); + Assert.Equal(new[] { straight }, Poker.BestHands(new[] { threeOf4, straight })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_straights() { const string straightTo8 = "4S 6H 7S 8D 5H"; const string straightTo9 = "5S 7H 8S 9D 6H"; - Assert.That(Poker.BestHands(new[] { straightTo8, straightTo9 }), Is.EqualTo(new[] { straightTo9 })); + Assert.Equal(new[] { straightTo9 }, Poker.BestHands(new[] { straightTo8, straightTo9 })); const string straightTo1 = "AS QH KS TD JH"; const string straightTo5 = "4S AH 3S 2D 5H"; - Assert.That(Poker.BestHands(new[] { straightTo1, straightTo5 }), Is.EqualTo(new[] { straightTo1 })); + Assert.Equal(new[] { straightTo1 }, Poker.BestHands(new[] { straightTo1, straightTo5 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Straight_vs_flush() { const string straightTo8 = "4S 6H 7S 8D 5H"; const string flushTo7 = "2S 4S 5S 6S 7S"; - Assert.That(Poker.BestHands(new[] { straightTo8, flushTo7 }), Is.EqualTo(new[] { flushTo7 })); + Assert.Equal(new[] { flushTo7 }, Poker.BestHands(new[] { straightTo8, flushTo7 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_flushes() { const string flushTo8 = "3H 6H 7H 8H 5H"; const string flushTo7 = "2S 4S 5S 6S 7S"; - Assert.That(Poker.BestHands(new[] { flushTo8, flushTo7 }), Is.EqualTo(new[] { flushTo8 })); + Assert.Equal(new[] { flushTo8 }, Poker.BestHands(new[] { flushTo8, flushTo7 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Flush_vs_full() { const string flushTo8 = "3H 6H 7H 8H 5H"; const string full = "4S 5H 4S 5D 4H"; - Assert.That(Poker.BestHands(new[] { full, flushTo8 }), Is.EqualTo(new[] { full })); + Assert.Equal(new[] { full }, Poker.BestHands(new[] { full, flushTo8 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_fulls() { const string fullOf4By9 = "4H 4S 4D 9S 9D"; const string fullOf5By8 = "5H 5S 5D 8S 8D"; - Assert.That(Poker.BestHands(new[] { fullOf4By9, fullOf5By8 }), Is.EqualTo(new[] { fullOf5By8 })); + Assert.Equal(new[] { fullOf5By8 }, Poker.BestHands(new[] { fullOf4By9, fullOf5By8 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Full_vs_square() { const string full = "4S 5H 4S 5D 4H"; const string squareOf3 = "3S 3H 2S 3D 3H"; - Assert.That(Poker.BestHands(new[] { full, squareOf3 }), Is.EqualTo(new[] { squareOf3 })); + Assert.Equal(new[] { squareOf3 }, Poker.BestHands(new[] { full, squareOf3 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_squares() { const string squareOf2 = "2S 2H 2S 8D 2H"; const string squareOf5 = "4S 5H 5S 5D 5H"; - Assert.That(Poker.BestHands(new[] { squareOf2, squareOf5 }), Is.EqualTo(new[] { squareOf5 })); + Assert.Equal(new[] { squareOf5 }, Poker.BestHands(new[] { squareOf2, squareOf5 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Square_vs_straight_flush() { const string squareOf5 = "4S 5H 5S 5D 5H"; const string straightFlushTo9 = "5S 7S 8S 9S 6S"; - Assert.That(Poker.BestHands(new[] { squareOf5, straightFlushTo9 }), Is.EqualTo(new[] { straightFlushTo9 })); + Assert.Equal(new[] { straightFlushTo9 }, Poker.BestHands(new[] { squareOf5, straightFlushTo9 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_straight_flushes() { const string straightFlushTo8 = "4H 6H 7H 8H 5H"; const string straightFlushTo9 = "5S 7S 8S 9S 6S"; - Assert.That(Poker.BestHands(new[] { straightFlushTo8, straightFlushTo9 }), - Is.EqualTo(new[] { straightFlushTo9 })); + Assert.Equal(new[] { straightFlushTo9 }, Poker.BestHands(new[] { straightFlushTo8, straightFlushTo9 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Three_hand_with_tie() { const string spadeStraightTo9 = "9S 8S 7S 6S 5S"; const string diamondStraightTo9 = "9D 8D 7D 6D 5D"; const string threeOf4 = "4D 4S 4H QS KS"; - Assert.That(Poker.BestHands(new[] { spadeStraightTo9, diamondStraightTo9, threeOf4 }), - Is.EqualTo(new[] { spadeStraightTo9, diamondStraightTo9 })); + Assert.Equal(new[] { spadeStraightTo9, diamondStraightTo9 }, Poker.BestHands(new[] { spadeStraightTo9, diamondStraightTo9, threeOf4 })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Straight_to_5_against_a_pair_of_jacks() { const string straightTo5 = "2S 4D 5C 3S AS"; const string twoJacks = "JD 8D 7D JC 5D"; - Assert.That(Poker.BestHands(new[] { straightTo5, twoJacks }), - Is.EqualTo(new[] { straightTo5 })); + Assert.Equal(new[] { straightTo5 }, Poker.BestHands(new[] { straightTo5, twoJacks })); } } diff --git a/exercises/pov/PovTest.cs b/exercises/pov/PovTest.cs index e0f9bf9b28..377cd8b807 100644 --- a/exercises/pov/PovTest.cs +++ b/exercises/pov/PovTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using Xunit; using System.Linq; public class PovTest @@ -87,74 +87,68 @@ public class PovTest }) }); - [Test] + [Fact] public void Reparent_singleton() { - Assert.That(Pov.FromPOV(x, singleton), Is.EqualTo(singleton_)); + Assert.Equal(singleton_, Pov.FromPOV(x, singleton)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reparent_flat() { - Assert.That(Pov.FromPOV(x, flat), Is.EqualTo(flat_)); + Assert.Equal(flat_, Pov.FromPOV(x, flat)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reparent_nested() { - Assert.That(Pov.FromPOV(x, nested), Is.EqualTo(nested_)); + Assert.Equal(nested_, Pov.FromPOV(x, nested)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reparent_kids() { - Assert.That(Pov.FromPOV(x, kids), Is.EqualTo(kids_)); + Assert.Equal(kids_, Pov.FromPOV(x, kids)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reparent_cousins() { - Assert.That(Pov.FromPOV(x, cousins), Is.EqualTo(cousins_)); + Assert.Equal(cousins_, Pov.FromPOV(x, cousins)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Reparent_from_POV_of_non_existent_node() { - Assert.That(Pov.FromPOV(x, leaf("foo")), Is.Null); + Assert.Null(Pov.FromPOV(x, leaf("foo"))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_not_be_able_to_find_a_missing_node() { var nodes = new[] { singleton, flat, kids, nested, cousins }.Select(graph => Pov.FromPOV("NOT THERE", graph)); - Assert.That(nodes, Is.All.Null); + Assert.All(nodes, node => + { + Assert.Null(node); + }); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cannot_trace_between_unconnected_nodes() { - Assert.That(Pov.TracePathBetween(x, "NOT THERE", cousins), Is.Null); + Assert.Null(Pov.TracePathBetween(x, "NOT THERE", cousins)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_trace_a_path_from_x_to_cousin() { - Assert.That(Pov.TracePathBetween(x, "cousin-1", cousins), Is.EquivalentTo(new[] { "x", "parent", "grandparent", "uncle", "cousin-1" })); + Assert.Equal(new[] { "x", "parent", "grandparent", "uncle", "cousin-1" }, Pov.TracePathBetween(x, "cousin-1", cousins)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_trace_from_a_leaf_to_a_leaf() { - Assert.That(Pov.TracePathBetween("kid-a", "cousin-0", cousins), Is.EquivalentTo(new[] { "kid-a", "x", "parent", "grandparent", "uncle", "cousin-0" })); + Assert.Equal(new[] { "kid-a", "x", "parent", "grandparent", "uncle", "cousin-0" }, Pov.TracePathBetween("kid-a", "cousin-0", cousins)); } } \ No newline at end of file diff --git a/exercises/prime-factors/PrimeFactorsTest.cs b/exercises/prime-factors/PrimeFactorsTest.cs index 720f859d84..3df695b976 100644 --- a/exercises/prime-factors/PrimeFactorsTest.cs +++ b/exercises/prime-factors/PrimeFactorsTest.cs @@ -1,81 +1,70 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class PrimeFactorsTest { - [Test] + [Fact] public void Test_1() { - Assert.That(PrimeFactors.For(1), Is.EqualTo(new int[0])); + Assert.Equal(new int[0], PrimeFactors.For(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_2() { - Assert.That(PrimeFactors.For(2), Is.EqualTo(new[] { 2 })); + Assert.Equal(new[] { 2 }, PrimeFactors.For(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_3() { - Assert.That(PrimeFactors.For(3), Is.EqualTo(new[] { 3 })); + Assert.Equal(new[] { 3 }, PrimeFactors.For(3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_4() { - Assert.That(PrimeFactors.For(4), Is.EqualTo(new[] { 2, 2 })); + Assert.Equal(new[] { 2, 2 }, PrimeFactors.For(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_6() { - Assert.That(PrimeFactors.For(6), Is.EqualTo(new[] { 2, 3 })); + Assert.Equal(new[] { 2, 3 }, PrimeFactors.For(6)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_8() { - Assert.That(PrimeFactors.For(8), Is.EqualTo(new[] { 2, 2, 2 })); + Assert.Equal(new[] { 2, 2, 2 }, PrimeFactors.For(8)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_9() { - Assert.That(PrimeFactors.For(9), Is.EqualTo(new[] { 3, 3 })); + Assert.Equal(new[] { 3, 3 }, PrimeFactors.For(9)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_27() { - Assert.That(PrimeFactors.For(27), Is.EqualTo(new[] { 3, 3, 3 })); + Assert.Equal(new[] { 3, 3, 3 }, PrimeFactors.For(27)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_625() { - Assert.That(PrimeFactors.For(625), Is.EqualTo(new[] { 5, 5, 5, 5 })); + Assert.Equal(new[] { 5, 5, 5, 5 }, PrimeFactors.For(625)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_901255() { - Assert.That(PrimeFactors.For(901255), Is.EqualTo(new[] { 5, 17, 23, 461 })); + Assert.Equal(new[] { 5, 17, 23, 461 }, PrimeFactors.For(901255)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_93819012551() { - Assert.That(PrimeFactors.For(93819012551), Is.EqualTo(new[] { 11, 9539, 894119 })); + Assert.Equal(new[] { 11, 9539, 894119 }, PrimeFactors.For(93819012551)); } } \ No newline at end of file diff --git a/exercises/protein-translation/ProteinTranslationTest.cs b/exercises/protein-translation/ProteinTranslationTest.cs index 46976f8167..0da3246d30 100644 --- a/exercises/protein-translation/ProteinTranslationTest.cs +++ b/exercises/protein-translation/ProteinTranslationTest.cs @@ -1,83 +1,85 @@ using System; -using NUnit.Framework; +using Xunit; -[TestFixture] public class ProteinTranslationTest { - [TestCase("AUG")] + [Theory] + [InlineData("AUG")] public void Identifies_methionine_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Methionine" })); + Assert.Equal(new[] { "Methionine" }, ProteinTranslation.Translate(codon)); } - [TestCase("UUU", Ignore = "Remove to run test case")] - [TestCase("UUC", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("UUU")] + [InlineData("UUC")] public void Identifies_phenylalanine_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Phenylalanine" })); + Assert.Equal(new[] { "Phenylalanine" }, ProteinTranslation.Translate(codon)); } - [TestCase("UUA", Ignore = "Remove to run test case")] - [TestCase("UUG", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("UUA")] + [InlineData("UUG")] public void Identifies_leucine_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Leucine" })); + Assert.Equal(new[] { "Leucine" }, ProteinTranslation.Translate(codon)); } - [TestCase("UCU", Ignore = "Remove to run test case")] - [TestCase("UCC", Ignore = "Remove to run test case")] - [TestCase("UCA", Ignore = "Remove to run test case")] - [TestCase("UCG", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("UCU")] + [InlineData("UCC")] + [InlineData("UCA")] + [InlineData("UCG")] public void Identifies_serine_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Serine" })); + Assert.Equal(new[] { "Serine" }, ProteinTranslation.Translate(codon)); } - [TestCase("UAU", Ignore = "Remove to run test case")] - [TestCase("UAC", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("UAU")] + [InlineData("UAC")] public void Identifies_tyrosine_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Tyrosine" })); + Assert.Equal(new[] { "Tyrosine" }, ProteinTranslation.Translate(codon)); } - [TestCase("UGU", Ignore = "Remove to run test case")] - [TestCase("UGC", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("UGU")] + [InlineData("UGC")] public void Identifies_cysteine_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Cysteine" })); + Assert.Equal(new[] { "Cysteine" }, ProteinTranslation.Translate(codon)); } - [TestCase("UGG", Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData("UGG")] public void Identifies_tryptophan_codons(string codon) { - Assert.That(ProteinTranslation.Translate(codon), Is.EquivalentTo(new[] { "Tryptophan" })); + Assert.Equal(new[] { "Tryptophan" }, ProteinTranslation.Translate(codon)); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Translates_rna_strand_into_correct_protein() { - Assert.That(ProteinTranslation.Translate("AUGUUUUGG"), Is.EquivalentTo(new[] { "Methionine", "Phenylalanine", "Tryptophan" })); + Assert.Equal(new[] { "Methionine", "Phenylalanine", "Tryptophan" }, ProteinTranslation.Translate("AUGUUUUGG")); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Stops_translation_if_stop_codon_present() { - Assert.That(ProteinTranslation.Translate("AUGUUUUAA"), Is.EquivalentTo(new[] { "Methionine", "Phenylalanine" })); + Assert.Equal(new[] { "Methionine", "Phenylalanine" }, ProteinTranslation.Translate("AUGUUUUAA")); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Stops_translation_of_longer_strand() { - Assert.That(ProteinTranslation.Translate("UGGUGUUAUUAAUGGUUU"), Is.EquivalentTo(new[] { "Tryptophan", "Cysteine", "Tyrosine" })); + Assert.Equal(new[] { "Tryptophan", "Cysteine", "Tyrosine" }, ProteinTranslation.Translate("UGGUGUUAUUAAUGGUUU")); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Throws_for_invalid_codons() { - Assert.That(() => ProteinTranslation.Translate("CARROT"), Throws.Exception); + Assert.Throws(() => ProteinTranslation.Translate("CARROT")); } } diff --git a/exercises/proverb/ProverbTest.cs b/exercises/proverb/ProverbTest.cs index 0a06ea901e..327dac4004 100644 --- a/exercises/proverb/ProverbTest.cs +++ b/exercises/proverb/ProverbTest.cs @@ -1,29 +1,26 @@ -using NUnit.Framework; +using Xunit; public class ProverbTest { - [Test] + [Fact] public void Line_one() { - Assert.That(Proverb.Line(1), Is.EqualTo("For want of a nail the shoe was lost.")); + Assert.Equal("For want of a nail the shoe was lost.", Proverb.Line(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Line_four() { - Assert.That(Proverb.Line(4), Is.EqualTo("For want of a rider the message was lost.")); + Assert.Equal("For want of a rider the message was lost.", Proverb.Line(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Line_seven() { - Assert.That(Proverb.Line(7), Is.EqualTo("And all for the want of a horseshoe nail.")); + Assert.Equal("And all for the want of a horseshoe nail.", Proverb.Line(7)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void All_lines() { const string expected = "For want of a nail the shoe was lost.\n" + @@ -34,6 +31,6 @@ public void All_lines() "For want of a battle the kingdom was lost.\n" + "And all for the want of a horseshoe nail."; - Assert.That(Proverb.AllLines(), Is.EqualTo(expected)); + Assert.Equal(expected, Proverb.AllLines()); } } diff --git a/exercises/pythagorean-triplet/PythagoreanTripletTest.cs b/exercises/pythagorean-triplet/PythagoreanTripletTest.cs index 8b3b363655..b82b57bd37 100644 --- a/exercises/pythagorean-triplet/PythagoreanTripletTest.cs +++ b/exercises/pythagorean-triplet/PythagoreanTripletTest.cs @@ -1,54 +1,49 @@ using System.Linq; -using NUnit.Framework; +using Xunit; -[TestFixture] public class PythagoreanTripletTest { - [Test] + [Fact] public void Calculates_the_sum() { - Assert.That(new Triplet(3, 4, 5).Sum(), Is.EqualTo(12)); + Assert.Equal(12, new Triplet(3, 4, 5).Sum()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Calculates_the_product() { - Assert.That(new Triplet(3, 4, 5).Product(), Is.EqualTo(60)); + Assert.Equal(60, new Triplet(3, 4, 5).Product()); } - [Ignore("Remove to run test")] - [TestCase(3, 4, 5, ExpectedResult = true)] - [TestCase(5, 6, 7, ExpectedResult = false)] - public bool Can_recognize_a_valid_pythagorean(int a, int b, int c) + [Theory(Skip = "Remove to run test")] + [InlineData(3, 4, 5, true)] + [InlineData(5, 6, 7, false)] + public void Can_recognize_a_valid_pythagorean(int a, int b, int c, bool expected) { - return new Triplet(a, b, c).IsPythagorean(); + Assert.Equal(expected, new Triplet(a, b, c).IsPythagorean()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_make_triplets_up_to_10() { var triplets = Triplet.Where(maxFactor: 10); var products = triplets.Select(x => x.Product()).OrderBy(x => x); - Assert.That(products, Is.EqualTo(new[] { 60, 480 })); + Assert.Equal(new[] { 60, 480 }, products); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_make_triplets_from_11_to_20() { var triplets = Triplet.Where(minFactor: 11, maxFactor: 20); var products = triplets.Select(x => x.Product()); - Assert.That(products, Is.EqualTo(new[] { 3840 })); + Assert.Equal(new[] { 3840 }, products); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_make_triplets_filtered_on_sum() { var triplets = Triplet.Where(sum: 180, maxFactor: 100); var products = triplets.Select(x => x.Product()).OrderBy(x => x); - Assert.That(products, Is.EqualTo(new[] { 118080, 168480, 202500 })); + Assert.Equal(new[] { 118080, 168480, 202500 }, products); } } \ No newline at end of file diff --git a/exercises/queen-attack/QueenAttackTest.cs b/exercises/queen-attack/QueenAttackTest.cs index c59655f2a9..88e5316dc5 100644 --- a/exercises/queen-attack/QueenAttackTest.cs +++ b/exercises/queen-attack/QueenAttackTest.cs @@ -1,9 +1,9 @@ using System; -using NUnit.Framework; +using Xunit; public class QueenAttackTest { - [Test] + [Fact] public void Cannot_occupy_same_space() { var white = new Queen(2, 4); @@ -11,56 +11,49 @@ public void Cannot_occupy_same_space() Assert.Throws(() => new Queens(white, black)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cannot_attack() { var queens = new Queens(new Queen(2, 3), new Queen(4, 7)); Assert.False(queens.CanAttack()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_attack_on_same_row() { var queens = new Queens(new Queen(2, 4), new Queen(2, 7)); Assert.True(queens.CanAttack()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_attack_on_same_column() { var queens = new Queens(new Queen(5, 4), new Queen(2, 4)); Assert.True(queens.CanAttack()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_attack_on_diagonal() { var queens = new Queens(new Queen(1, 1), new Queen(6, 6)); Assert.True(queens.CanAttack()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_attack_on_other_diagonal() { var queens = new Queens(new Queen(0, 6), new Queen(1, 7)); Assert.True(queens.CanAttack()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_attack_on_yet_another_diagonal() { var queens = new Queens(new Queen(4, 1), new Queen(6, 3)); Assert.True(queens.CanAttack()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_attack_on_a_diagonal_slanted_the_other_way() { var queens = new Queens(new Queen(6, 1), new Queen(1, 6)); diff --git a/exercises/rail-fence-cipher/RailFenceCipherTest.cs b/exercises/rail-fence-cipher/RailFenceCipherTest.cs index f9de838c4d..f37d4852b3 100644 --- a/exercises/rail-fence-cipher/RailFenceCipherTest.cs +++ b/exercises/rail-fence-cipher/RailFenceCipherTest.cs @@ -1,63 +1,58 @@ -using NUnit.Framework; +using Xunit; public class RailFenceCipherTest { - [Test] + [Fact] public void Encode_with_two_rails() { var railFenceCipher = new RailFenceCipher(2); var actual = railFenceCipher.Encode("XOXOXOXOXOXOXOXOXO"); var expected = "XXXXXXXXXOOOOOOOOO"; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Encode_with_three_rails() { var railFenceCipher = new RailFenceCipher(3); var actual = railFenceCipher.Encode("WEAREDISCOVEREDFLEEATONCE"); var expected = "WECRLTEERDSOEEFEAOCAIVDEN"; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Encode_with_ending_in_the_middle() { var railFenceCipher = new RailFenceCipher(4); var actual = railFenceCipher.Encode("EXERCISES"); var expected = "ESXIEECSR"; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decode_with_three_rails() { var railFenceCipher = new RailFenceCipher(3); var actual = railFenceCipher.Decode("TEITELHDVLSNHDTISEIIEA"); var expected = "THEDEVILISINTHEDETAILS"; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decode_with_five_rails() { var railFenceCipher = new RailFenceCipher(5); var actual = railFenceCipher.Decode("EIEXMSMESAORIWSCE"); var expected = "EXERCISMISAWESOME"; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decode_with_six_rails() { var railFenceCipher = new RailFenceCipher(6); var actual = railFenceCipher.Decode("133714114238148966225439541018335470986172518171757571896261"); var expected = "112358132134558914423337761098715972584418167651094617711286"; - Assert.That(actual, Is.EqualTo(expected)); + Assert.Equal(expected, actual); } } \ No newline at end of file diff --git a/exercises/raindrops/RaindropsTest.cs b/exercises/raindrops/RaindropsTest.cs index 0a3f14c334..af3491015c 100644 --- a/exercises/raindrops/RaindropsTest.cs +++ b/exercises/raindrops/RaindropsTest.cs @@ -1,50 +1,50 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class RaindropsTest { - [TestCase(1, ExpectedResult = "1")] - [TestCase(52, ExpectedResult = "52")] - [TestCase(12121, ExpectedResult = "12121")] - public string Non_primes_pass_through(int number) + [Theory] + [InlineData(1, "1")] + [InlineData(52, "52")] + [InlineData(12121, "12121")] + public void Non_primes_pass_through(int number, string expected) { - return Raindrops.Convert(number); + Assert.Equal(expected, Raindrops.Convert(number)); } - [Ignore("Remove to run test")] - [TestCase(3)] - [TestCase(6)] - [TestCase(9)] + [Theory(Skip = "Remove to run test")] + [InlineData(3)] + [InlineData(6)] + [InlineData(9)] public void Numbers_containing_3_as_a_prime_factor_give_pling(int number) { - Assert.That(Raindrops.Convert(number), Is.EqualTo("Pling")); + Assert.Equal("Pling", Raindrops.Convert(number)); } - [Ignore("Remove to run test")] - [TestCase(5)] - [TestCase(10)] - [TestCase(25)] + [Theory(Skip = "Remove to run test")] + [InlineData(5)] + [InlineData(10)] + [InlineData(25)] public void Numbers_containing_5_as_a_prime_factor_give_plang(int number) { - Assert.That(Raindrops.Convert(number), Is.EqualTo("Plang")); + Assert.Equal("Plang", Raindrops.Convert(number)); } - [Ignore("Remove to run test")] - [TestCase(7)] - [TestCase(14)] - [TestCase(49)] + [Theory(Skip = "Remove to run test")] + [InlineData(7)] + [InlineData(14)] + [InlineData(49)] public void Numbers_containing_7_as_a_prime_factor_give_plong(int number) { - Assert.That(Raindrops.Convert(number), Is.EqualTo("Plong")); + Assert.Equal("Plong", Raindrops.Convert(number)); } - [Ignore("Remove to run test")] - [TestCase(15, ExpectedResult = "PlingPlang")] - [TestCase(21, ExpectedResult = "PlingPlong")] - [TestCase(35, ExpectedResult = "PlangPlong")] - [TestCase(105, ExpectedResult = "PlingPlangPlong")] - public string Numbers_containing_multiple_prime_factors_give_all_results_concatenated(int number) + [Theory(Skip = "Remove to run test")] + [InlineData(15, "PlingPlang")] + [InlineData(21, "PlingPlong")] + [InlineData(35, "PlangPlong")] + [InlineData(105, "PlingPlangPlong")] + public void Numbers_containing_multiple_prime_factors_give_all_results_concatenated(int number, string expected) { - return Raindrops.Convert(number); + Assert.Equal(expected, Raindrops.Convert(number)); } } \ No newline at end of file diff --git a/exercises/react/ReactTest.cs b/exercises/react/ReactTest.cs index 0501543862..b3feaedef3 100644 --- a/exercises/react/ReactTest.cs +++ b/exercises/react/ReactTest.cs @@ -1,34 +1,32 @@ -using NUnit.Framework; +using Xunit; using System.Collections.Generic; public class ReactTest { - [Test] + [Fact] public void Setting_the_value_of_an_input_cell_changes_the_observable_value() { var reactor = new Reactor(); var inputCell1 = reactor.CreateInputCell(1); - Assert.That(inputCell1.Value, Is.EqualTo(1)); + Assert.Equal(1, inputCell1.Value); inputCell1.Value = 2; - Assert.That(inputCell1.Value, Is.EqualTo(2)); + Assert.Equal(2, inputCell1.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void The_value_of_a_compute_is_determined_by_the_value_of_the_dependencies() { var reactor = new Reactor(); var inputCell1 = reactor.CreateInputCell(1); var computeCell1 = reactor.CreateComputeCell(new[] { inputCell1 }, (values) => values[0] + 1); - Assert.That(computeCell1.Value, Is.EqualTo(2)); + Assert.Equal(2, computeCell1.Value); inputCell1.Value = 2; - Assert.That(computeCell1.Value, Is.EqualTo(3)); + Assert.Equal(3, computeCell1.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Compute_cells_can_depend_on_other_compute_cells() { var reactor = new Reactor(); @@ -37,13 +35,12 @@ public void Compute_cells_can_depend_on_other_compute_cells() var computeCell2 = reactor.CreateComputeCell(new[] { inputCell1 }, (values) => values[0] - 1); var computeCell3 = reactor.CreateComputeCell(new[] { computeCell1, computeCell2 }, (values) => values[0] * values[1]); - Assert.That(computeCell3.Value, Is.EqualTo(0)); + Assert.Equal(0, computeCell3.Value); inputCell1.Value = 3; - Assert.That(computeCell3.Value, Is.EqualTo(8)); + Assert.Equal(8, computeCell3.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Compute_cells_can_have_callbacks() { var reactor = new Reactor(); @@ -52,13 +49,12 @@ public void Compute_cells_can_have_callbacks() var observed = new List(); computeCell1.Changed += (sender, value) => observed.Add(value); - Assert.That(observed, Is.Empty); + Assert.Empty(observed); inputCell1.Value = 2; - Assert.That(observed, Is.EquivalentTo(new[] { 3 })); + Assert.Equal(new[] { 3 }, observed); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Callbacks_only_trigger_on_change() { var reactor = new Reactor(); @@ -68,15 +64,14 @@ public void Callbacks_only_trigger_on_change() computecell1.Changed += (sender, value) => observerCalled++; inputCell1.Value = 1; - Assert.That(observerCalled, Is.EqualTo(0)); + Assert.Equal(0, observerCalled); inputCell1.Value = 2; - Assert.That(observerCalled, Is.EqualTo(0)); + Assert.Equal(0, observerCalled); inputCell1.Value = 3; - Assert.That(observerCalled, Is.EqualTo(1)); + Assert.Equal(1, observerCalled); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Callbacks_can_be_removed() { var reactor = new Reactor(); @@ -92,17 +87,16 @@ public void Callbacks_can_be_removed() computeCell1.Changed += changedHandler2; inputCell1.Value = 2; - Assert.That(observed1, Is.EquivalentTo(new[] { 3 })); - Assert.That(observed2, Is.EquivalentTo(new[] { 3 })); + Assert.Equal(new[] { 3 }, observed1); + Assert.Equal(new[] { 3 }, observed2); computeCell1.Changed -= changedHandler1; inputCell1.Value = 3; - Assert.That(observed1, Is.EquivalentTo(new[] { 3 })); - Assert.That(observed2, Is.EquivalentTo(new[] { 3, 4 })); + Assert.Equal(new[] { 3 }, observed1); + Assert.Equal(new[] { 3, 4 }, observed2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Callbacks_should_only_be_called_once_even_if_multiple_dependencies_have_changed() { var reactor = new Reactor(); @@ -116,6 +110,6 @@ public void Callbacks_should_only_be_called_once_even_if_multiple_dependencies_h computeCell4.Changed += (sender, value) => changed4++; inputCell1.Value = 3; - Assert.That(changed4, Is.EqualTo(1)); + Assert.Equal(1, changed4); } } diff --git a/exercises/rectangles/RectanglesTest.cs b/exercises/rectangles/RectanglesTest.cs index bace8c3b95..041165ded8 100644 --- a/exercises/rectangles/RectanglesTest.cs +++ b/exercises/rectangles/RectanglesTest.cs @@ -1,32 +1,29 @@ -using NUnit.Framework; +using Xunit; public class RectanglesTest { - [Test] + [Fact] public void No_rows() { var input = new string[0]; - Assert.That(Rectangles.Count(input), Is.EqualTo(0)); + Assert.Equal(0, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void No_columns() { var input = new[] { "" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(0)); + Assert.Equal(0, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void No_rectangles() { var input = new[] { " " }; - Assert.That(Rectangles.Count(input), Is.EqualTo(0)); + Assert.Equal(0, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_rectangle() { var input = new[] @@ -35,11 +32,10 @@ public void One_rectangle() "| |", "+-+" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(1)); + Assert.Equal(1, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_rectangles_without_shared_parts() { var input = new[] @@ -50,11 +46,10 @@ public void Two_rectangles_without_shared_parts() "| | ", "+-+ " }; - Assert.That(Rectangles.Count(input), Is.EqualTo(2)); + Assert.Equal(2, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Five_rectangles_with_shared_parts() { var input = new[] @@ -65,11 +60,10 @@ public void Five_rectangles_with_shared_parts() "| | |", "+-+-+" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(5)); + Assert.Equal(5, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Only_complete_rectangles_are_counted() { var input = new[] @@ -80,11 +74,10 @@ public void Only_complete_rectangles_are_counted() "| | -", "+-+-+" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(1)); + Assert.Equal(1, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rectangles_can_be_of_different_sizes() { var input = new[] @@ -95,11 +88,10 @@ public void Rectangles_can_be_of_different_sizes() "| | |", "+---+-------+" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(3)); + Assert.Equal(3, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Corner_is_required_for_a_rectangle_to_be_complete() { var input = new[] @@ -110,11 +102,10 @@ public void Corner_is_required_for_a_rectangle_to_be_complete() "| | |", "+---+-------+" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(2)); + Assert.Equal(2, Rectangles.Count(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Large_input_with_many_rectangles() { var input = new[] @@ -128,6 +119,6 @@ public void Large_input_with_many_rectangles() "+------+ | |", " +-+" }; - Assert.That(Rectangles.Count(input), Is.EqualTo(60)); + Assert.Equal(60, Rectangles.Count(input)); } } \ No newline at end of file diff --git a/exercises/rna-transcription/ComplementTest.cs b/exercises/rna-transcription/ComplementTest.cs index 6820025a80..dc25888d63 100644 --- a/exercises/rna-transcription/ComplementTest.cs +++ b/exercises/rna-transcription/ComplementTest.cs @@ -1,39 +1,34 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class ComplementTest { - [Test] + [Fact] public void Rna_complement_of_cytosine_is_guanine() { - Assert.That(Complement.OfDna("C"), Is.EqualTo("G")); + Assert.Equal("G", Complement.OfDna("C")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rna_complement_of_guanine_is_cytosine() { - Assert.That(Complement.OfDna("G"), Is.EqualTo("C")); + Assert.Equal("C", Complement.OfDna("G")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rna_complement_of_thymine_is_adenine() { - Assert.That(Complement.OfDna("T"), Is.EqualTo("A")); + Assert.Equal("A", Complement.OfDna("T")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rna_complement_of_adenine_is_uracil() { - Assert.That(Complement.OfDna("A"), Is.EqualTo("U")); + Assert.Equal("U", Complement.OfDna("A")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Rna_complement() { - Assert.That(Complement.OfDna("ACGTGGTCTTAA"), Is.EqualTo("UGCACCAGAAUU")); + Assert.Equal("UGCACCAGAAUU", Complement.OfDna("ACGTGGTCTTAA")); } } \ No newline at end of file diff --git a/exercises/robot-name/RobotNameTest.cs b/exercises/robot-name/RobotNameTest.cs index 9477a6583d..b6f5e5ff6d 100644 --- a/exercises/robot-name/RobotNameTest.cs +++ b/exercises/robot-name/RobotNameTest.cs @@ -1,43 +1,33 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class RobotNameTest { - private Robot robot; + private readonly Robot robot = new Robot(); - [SetUp] - public void Setup() - { - robot = new Robot(); - } - - [Test] + [Fact] public void Robot_has_a_name() { - StringAssert.IsMatch(@"[A-Z]{2}\d{3}", robot.Name); + Assert.Matches(@"[A-Z]{2}\d{3}", robot.Name); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Name_is_the_same_each_time() { - Assert.That(robot.Name, Is.EqualTo(robot.Name)); + Assert.Equal(robot.Name, robot.Name); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Different_robots_have_different_names() { var robot2 = new Robot(); - Assert.That(robot.Name, Is.Not.EqualTo(robot2.Name)); + Assert.NotEqual(robot2.Name, robot.Name); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_reset_the_name() { var originalName = robot.Name; robot.Reset(); - Assert.That(robot.Name, Is.Not.EqualTo(originalName)); + Assert.NotEqual(originalName, robot.Name); } } \ No newline at end of file diff --git a/exercises/robot-simulator/RobotSimulatorTest.cs b/exercises/robot-simulator/RobotSimulatorTest.cs index ed4d9b807a..db5be514b7 100644 --- a/exercises/robot-simulator/RobotSimulatorTest.cs +++ b/exercises/robot-simulator/RobotSimulatorTest.cs @@ -1,64 +1,59 @@ -using NUnit.Framework; +using Xunit; public class RobotSimulatorTest { - [Test] + [Fact] public void Turn_right_edge_case() { var robot = new RobotSimulator(Bearing.West, new Coordinate(0, 0)); robot.TurnRight(); - Assert.That(robot.Bearing, Is.EqualTo(Bearing.North)); + Assert.Equal(Bearing.North, robot.Bearing); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Turn_left_edge_case() { var robot = new RobotSimulator(Bearing.North, new Coordinate(0, 0)); robot.TurnLeft(); - Assert.That(robot.Bearing, Is.EqualTo(Bearing.West)); + Assert.Equal(Bearing.West, robot.Bearing); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Robbie() { var robbie = new RobotSimulator(Bearing.East, new Coordinate(-2, 1)); - Assert.That(robbie.Bearing, Is.EqualTo(Bearing.East)); - Assert.That(robbie.Coordinate, Is.EqualTo(new Coordinate(-2, 1))); + Assert.Equal(Bearing.East, robbie.Bearing); + Assert.Equal(new Coordinate(-2, 1), robbie.Coordinate); robbie.Simulate("RLAALAL"); - Assert.That(robbie.Bearing, Is.EqualTo(Bearing.West)); - Assert.That(robbie.Coordinate, Is.EqualTo(new Coordinate(0, 2))); + Assert.Equal(Bearing.West, robbie.Bearing); + Assert.Equal(new Coordinate(0, 2), robbie.Coordinate); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Clutz() { var clutz = new RobotSimulator(Bearing.North, new Coordinate(0, 0)); clutz.Simulate("LAAARALA"); - Assert.That(clutz.Bearing, Is.EqualTo(Bearing.West)); - Assert.That(clutz.Coordinate, Is.EqualTo(new Coordinate(-4, 1))); + Assert.Equal(Bearing.West, clutz.Bearing); + Assert.Equal(new Coordinate(-4, 1), clutz.Coordinate); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sphero() { var sphero = new RobotSimulator(Bearing.East, new Coordinate(2, -7)); sphero.Simulate("RRAAAAALA"); - Assert.That(sphero.Bearing, Is.EqualTo(Bearing.South)); - Assert.That(sphero.Coordinate, Is.EqualTo(new Coordinate(-3, -8))); + Assert.Equal(Bearing.South, sphero.Bearing); + Assert.Equal(new Coordinate(-3, -8), sphero.Coordinate); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Roomba() { var roomba = new RobotSimulator(Bearing.South, new Coordinate(8, 4)); roomba.Simulate("LAAARRRALLLL"); - Assert.That(roomba.Bearing, Is.EqualTo(Bearing.North)); - Assert.That(roomba.Coordinate, Is.EqualTo(new Coordinate(11, 5))); + Assert.Equal(Bearing.North, roomba.Bearing); + Assert.Equal(new Coordinate(11, 5), roomba.Coordinate); } } \ No newline at end of file diff --git a/exercises/roman-numerals/RomanNumeralsTest.cs b/exercises/roman-numerals/RomanNumeralsTest.cs index 69c24238d9..c9cfafde60 100644 --- a/exercises/roman-numerals/RomanNumeralsTest.cs +++ b/exercises/roman-numerals/RomanNumeralsTest.cs @@ -1,29 +1,29 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class RomanNumeralsTest { - [TestCase(0, ExpectedResult = "")] - [TestCase(1, ExpectedResult = "I", Ignore = "Remove to run test case")] - [TestCase(2, ExpectedResult = "II", Ignore = "Remove to run test case")] - [TestCase(3, ExpectedResult = "III", Ignore = "Remove to run test case")] - [TestCase(4, ExpectedResult = "IV", Ignore = "Remove to run test case")] - [TestCase(5, ExpectedResult = "V", Ignore = "Remove to run test case")] - [TestCase(6, ExpectedResult = "VI", Ignore = "Remove to run test case")] - [TestCase(9, ExpectedResult = "IX", Ignore = "Remove to run test case")] - [TestCase(27, ExpectedResult = "XXVII", Ignore = "Remove to run test case")] - [TestCase(48, ExpectedResult = "XLVIII", Ignore = "Remove to run test case")] - [TestCase(59, ExpectedResult = "LIX", Ignore = "Remove to run test case")] - [TestCase(93, ExpectedResult = "XCIII", Ignore = "Remove to run test case")] - [TestCase(141, ExpectedResult = "CXLI", Ignore = "Remove to run test case")] - [TestCase(163, ExpectedResult = "CLXIII", Ignore = "Remove to run test case")] - [TestCase(402, ExpectedResult = "CDII", Ignore = "Remove to run test case")] - [TestCase(575, ExpectedResult = "DLXXV", Ignore = "Remove to run test case")] - [TestCase(911, ExpectedResult = "CMXI", Ignore = "Remove to run test case")] - [TestCase(1024, ExpectedResult = "MXXIV", Ignore = "Remove to run test case")] - [TestCase(3000, ExpectedResult = "MMM", Ignore = "Remove to run test case")] - public string Convert_roman_to_arabic_numerals(int arabicNumeral) + [Theory] + [InlineData(0, "")] + [InlineData(1, "I")] + [InlineData(2, "II")] + [InlineData(3, "III")] + [InlineData(4, "IV")] + [InlineData(5, "V")] + [InlineData(6, "VI")] + [InlineData(9, "IX")] + [InlineData(27, "XXVII")] + [InlineData(48, "XLVIII")] + [InlineData(59, "LIX")] + [InlineData(93, "XCIII")] + [InlineData(141, "CXLI")] + [InlineData(163, "CLXIII")] + [InlineData(402, "CDII")] + [InlineData(575, "DLXXV")] + [InlineData(911, "CMXI")] + [InlineData(1024, "MXXIV")] + [InlineData(3000, "MMM")] + public void Convert_roman_to_arabic_numerals(int arabicNumeral, string expected) { - return arabicNumeral.ToRoman(); + Assert.Equal(expected, arabicNumeral.ToRoman()); } } \ No newline at end of file diff --git a/exercises/run-length-encoding/RunLengthEncodingTest.cs b/exercises/run-length-encoding/RunLengthEncodingTest.cs index ab48b145cd..f1808d2274 100644 --- a/exercises/run-length-encoding/RunLengthEncodingTest.cs +++ b/exercises/run-length-encoding/RunLengthEncodingTest.cs @@ -1,66 +1,60 @@ -using NUnit.Framework; +using Xunit; public class RunLengthEncodingTest { - [Test] + [Fact] public void Encode_simple() { const string input = "AABBBCCCC"; const string expected = "2A3B4C"; - Assert.That(RunLengthEncoding.Encode(input), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Encode(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decode_simple() { const string input = "2A3B4C"; const string expected = "AABBBCCCC"; - Assert.That(RunLengthEncoding.Decode(input), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Decode(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Encode_with_single_values() { const string input = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"; const string expected = "12WB12W3B24WB"; - Assert.That(RunLengthEncoding.Encode(input), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Encode(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decode_with_single_values() { const string input = "12WB12W3B24WB"; const string expected = "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWB"; - Assert.That(RunLengthEncoding.Decode(input), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Decode(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Encode_and_then_decode() { const string input = "zzz ZZ zZ"; const string expected = "zzz ZZ zZ"; - Assert.That(RunLengthEncoding.Decode(RunLengthEncoding.Encode(input)), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Decode(RunLengthEncoding.Encode(input))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Encode_unicode() { const string input = "⏰⚽⚽⚽⭐⭐⏰"; const string expected = "⏰3⚽2⭐⏰"; - Assert.That(RunLengthEncoding.Encode(input), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Encode(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Decode_unicode() { const string input = "⏰3⚽2⭐⏰"; const string expected = "⏰⚽⚽⚽⭐⭐⏰"; - Assert.That(RunLengthEncoding.Decode(input), Is.EqualTo(expected)); + Assert.Equal(expected, RunLengthEncoding.Decode(input)); } } \ No newline at end of file diff --git a/exercises/saddle-points/SaddlePointTest.cs b/exercises/saddle-points/SaddlePointTest.cs index 5458ced1cb..74b7eacfc7 100644 --- a/exercises/saddle-points/SaddlePointTest.cs +++ b/exercises/saddle-points/SaddlePointTest.cs @@ -1,9 +1,9 @@ using System; -using NUnit.Framework; +using Xunit; public class SaddlePointTests { - [Test] + [Fact] public void Readme_example() { var values = new[,] @@ -13,11 +13,10 @@ public void Readme_example() { 6, 6, 7 } }; var actual = new SaddlePoints(values).Calculate(); - Assert.That(actual, Is.EqualTo(new [] { Tuple.Create(1, 0)})); + Assert.Equal(new [] { Tuple.Create(1, 0)}, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void No_saddle_point() { var values = new[,] @@ -26,11 +25,10 @@ public void No_saddle_point() { 1, 2 } }; var actual = new SaddlePoints(values).Calculate(); - Assert.That(actual, Is.Empty); + Assert.Empty(actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Saddle_point() { var values = new[,] @@ -39,11 +37,10 @@ public void Saddle_point() { 3, 4 } }; var actual = new SaddlePoints(values).Calculate(); - Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(0, 1) })); + Assert.Equal(new[] { Tuple.Create(0, 1) }, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Another_saddle_point() { var values = new[,] @@ -53,11 +50,10 @@ public void Another_saddle_point() { 3, 4, 8, 6, 7 } }; var actual = new SaddlePoints(values).Calculate(); - Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(2, 2) })); + Assert.Equal(new[] { Tuple.Create(2, 2) }, actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_saddle_points() { var values = new[,] @@ -67,6 +63,6 @@ public void Multiple_saddle_points() { 1, 5, 4 } }; var actual = new SaddlePoints(values).Calculate(); - Assert.That(actual, Is.EqualTo(new[] { Tuple.Create(0, 1), Tuple.Create(1, 1), Tuple.Create(2, 1) })); + Assert.Equal(new[] { Tuple.Create(0, 1), Tuple.Create(1, 1), Tuple.Create(2, 1) }, actual); } } \ No newline at end of file diff --git a/exercises/say/Example.cs b/exercises/say/Example.cs index 2898326946..e9660addd6 100644 --- a/exercises/say/Example.cs +++ b/exercises/say/Example.cs @@ -8,7 +8,7 @@ public static string InEnglish(long number) { if (number < 0L || number >= 1000000000000L) { - throw new ArgumentException("Number out of range."); + throw new ArgumentOutOfRangeException("Number out of range."); } if (number == 0L) diff --git a/exercises/say/SayTest.cs b/exercises/say/SayTest.cs index db0d3d9652..332fe95ba5 100644 --- a/exercises/say/SayTest.cs +++ b/exercises/say/SayTest.cs @@ -1,115 +1,101 @@ -using NUnit.Framework; +using System; +using Xunit; public class SayTest { - [Test] + [Fact] public void Zero() { - Assert.That(Say.InEnglish(0L), Is.EqualTo("zero")); + Assert.Equal("zero", Say.InEnglish(0L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One() { - Assert.That(Say.InEnglish(1L), Is.EqualTo("one")); + Assert.Equal("one", Say.InEnglish(1L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Fourteen() { - Assert.That(Say.InEnglish(14L), Is.EqualTo("fourteen")); + Assert.Equal("fourteen", Say.InEnglish(14L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Twenty() { - Assert.That(Say.InEnglish(20L), Is.EqualTo("twenty")); + Assert.Equal("twenty", Say.InEnglish(20L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Twenty_two() { - Assert.That(Say.InEnglish(22L), Is.EqualTo("twenty-two")); + Assert.Equal("twenty-two", Say.InEnglish(22L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_hundred() { - Assert.That(Say.InEnglish(100L), Is.EqualTo("one hundred")); + Assert.Equal("one hundred", Say.InEnglish(100L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_hundred_twenty_three() { - Assert.That(Say.InEnglish(123L), Is.EqualTo("one hundred twenty-three")); + Assert.Equal("one hundred twenty-three", Say.InEnglish(123L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_thousand() { - Assert.That(Say.InEnglish(1000L), Is.EqualTo("one thousand")); + Assert.Equal("one thousand", Say.InEnglish(1000L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_thousand_two_hundred_thirty_four() { - Assert.That(Say.InEnglish(1234L), Is.EqualTo("one thousand two hundred thirty-four")); + Assert.Equal("one thousand two hundred thirty-four", Say.InEnglish(1234L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_million() { - Assert.That(Say.InEnglish(1000000L), Is.EqualTo("one million")); + Assert.Equal("one million", Say.InEnglish(1000000L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_million_two() { - Assert.That(Say.InEnglish(1000002L), Is.EqualTo("one million two")); + Assert.Equal("one million two", Say.InEnglish(1000002L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_million_two_thousand_three_hundred_forty_five() { - Assert.That(Say.InEnglish(1002345L), Is.EqualTo("one million two thousand three hundred forty-five")); + Assert.Equal("one million two thousand three hundred forty-five", Say.InEnglish(1002345L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_billion() { - Assert.That(Say.InEnglish(1000000000L), Is.EqualTo("one billion")); + Assert.Equal("one billion", Say.InEnglish(1000000000L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void A_big_number() { - Assert.That(Say.InEnglish(987654321123L), Is.EqualTo("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three")); + Assert.Equal("nine hundred eighty-seven billion six hundred fifty-four million three hundred twenty-one thousand one hundred twenty-three", Say.InEnglish(987654321123L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Lower_bound() { - Assert.That(() => Say.InEnglish(-1L), Throws.Exception); + Assert.Throws(() => Say.InEnglish(-1L)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Upper_bound() { - Assert.That(() => Say.InEnglish(1000000000000L), Throws.Exception); + Assert.Throws(() => Say.InEnglish(1000000000000L)); } } \ No newline at end of file diff --git a/exercises/scale-generator/ScaleGeneratorTest.cs b/exercises/scale-generator/ScaleGeneratorTest.cs index 30297ad1a0..42ea887f53 100644 --- a/exercises/scale-generator/ScaleGeneratorTest.cs +++ b/exercises/scale-generator/ScaleGeneratorTest.cs @@ -1,129 +1,116 @@ -using NUnit.Framework; +using Xunit; public class ScaleGeneratorTest { - [Test] + [Fact] public void Major_scale() { var major = ScaleGenerator.Pitches("C", "MMmMMMm"); var expected = new[] {"C", "D", "E", "F", "G", "A", "B"}; - Assert.That(major, Is.EqualTo(expected)); + Assert.Equal(expected, major); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Another_major_scale() { var major = ScaleGenerator.Pitches("G", "MMmMMMm"); var expected = new[] {"G", "A", "B", "C", "D", "E", "F#"}; - Assert.That(major, Is.EqualTo(expected)); + Assert.Equal(expected, major); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Minor_scale() { var minor = ScaleGenerator.Pitches("f#", "MmMMmMM"); var expected = new[] {"F#", "G#", "A", "B", "C#", "D", "E"}; - Assert.That(minor, Is.EqualTo(expected)); + Assert.Equal(expected, minor); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Another_minor_scale() { var minor = ScaleGenerator.Pitches("bb", "MmMMmMM"); var expected = new[] {"Bb", "C", "Db", "Eb", "F", "Gb", "Ab"}; - Assert.That(minor, Is.EqualTo(expected)); + Assert.Equal(expected, minor); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Dorian_mode() { var dorian = ScaleGenerator.Pitches("d", "MmMMMmM"); var expected = new[] {"D", "E", "F", "G", "A", "B", "C"}; - Assert.That(dorian, Is.EqualTo(expected)); + Assert.Equal(expected, dorian); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Mixolydian_mode() { var mixolydian = ScaleGenerator.Pitches("Eb", "MMmMMmM"); var expected = new[] {"Eb", "F", "G", "Ab", "Bb", "C", "Db"}; - Assert.That(mixolydian, Is.EqualTo(expected)); + Assert.Equal(expected, mixolydian); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Lydian_mode() { var lydian = ScaleGenerator.Pitches("a", "MMMmMMm"); var expected = new[] {"A", "B", "C#", "D#", "E", "F#", "G#"}; - Assert.That(lydian, Is.EqualTo(expected)); + Assert.Equal(expected, lydian); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Phrygian_mode() { var phrygian = ScaleGenerator.Pitches("e", "mMMMmMM"); var expected = new[] {"E", "F", "G", "A", "B", "C", "D"}; - Assert.That(phrygian, Is.EqualTo(expected)); + Assert.Equal(expected, phrygian); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Locrian_mode() { var locrian = ScaleGenerator.Pitches("g", "mMMmMMM"); var expected = new[] {"G", "Ab", "Bb", "C", "Db", "Eb", "F"}; - Assert.That(locrian, Is.EqualTo(expected)); + Assert.Equal(expected, locrian); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Harmonic_minor() { var harmonicMinor = ScaleGenerator.Pitches("d", "MmMMmAm"); var expected = new[] {"D", "E", "F", "G", "A", "Bb", "Db"}; - Assert.That(harmonicMinor, Is.EqualTo(expected)); + Assert.Equal(expected, harmonicMinor); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Octatonic() { var octatonic = ScaleGenerator.Pitches("C", "MmMmMmMm"); var expected = new[] {"C", "D", "D#", "F", "F#", "G#", "A", "B"}; - Assert.That(octatonic, Is.EqualTo(expected)); + Assert.Equal(expected, octatonic); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Hexatonic() { var hexatonic = ScaleGenerator.Pitches("Db", "MMMMMM"); var expected = new[] {"Db", "Eb", "F", "G", "A", "B"}; - Assert.That(hexatonic, Is.EqualTo(expected)); + Assert.Equal(expected, hexatonic); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Pentatonic() { var pentatonic = ScaleGenerator.Pitches("A", "MMAMA"); var expected = new[] {"A", "B", "C#", "E", "F#"}; - Assert.That(pentatonic, Is.EqualTo(expected)); + Assert.Equal(expected, pentatonic); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Enigmatic() { var enigmatic = ScaleGenerator.Pitches("G", "mAMMMmm"); var expected = new[] {"G", "G#", "B", "C#", "D#", "F", "F#"}; - Assert.That(enigmatic, Is.EqualTo(expected)); + Assert.Equal(expected, enigmatic); } } \ No newline at end of file diff --git a/exercises/scrabble-score/ScrabbleScoreTest.cs b/exercises/scrabble-score/ScrabbleScoreTest.cs index 1f353e7cb4..7c4308d526 100644 --- a/exercises/scrabble-score/ScrabbleScoreTest.cs +++ b/exercises/scrabble-score/ScrabbleScoreTest.cs @@ -1,67 +1,58 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class ScrabbleScoreTest { - [Test] + [Fact] public void Empty_word_scores_zero() { - Assert.That(Scrabble.Score(""), Is.EqualTo(0)); + Assert.Equal(0, Scrabble.Score("")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Whitespace_scores_zero() { - Assert.That(Scrabble.Score(" \t\n"), Is.EqualTo(0)); + Assert.Equal(0, Scrabble.Score(" \t\n")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Null_scores_zero() { - Assert.That(Scrabble.Score(null), Is.EqualTo(0)); + Assert.Equal(0, Scrabble.Score(null)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Scores_very_short_word() { - Assert.That(Scrabble.Score("a"), Is.EqualTo(1)); + Assert.Equal(1, Scrabble.Score("a")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Scores_other_very_short_word() { - Assert.That(Scrabble.Score("f"), Is.EqualTo(4)); + Assert.Equal(4, Scrabble.Score("f")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Simple_word_scores_the_number_of_letters() { - Assert.That(Scrabble.Score("street"), Is.EqualTo(6)); + Assert.Equal(6, Scrabble.Score("street")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Complicated_word_scores_more() { - Assert.That(Scrabble.Score("quirky"), Is.EqualTo(22)); + Assert.Equal(22, Scrabble.Score("quirky")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Scores_are_case_insensitive() { - Assert.That(Scrabble.Score("OXYPHENBUTAZONE"), Is.EqualTo(41)); + Assert.Equal(41, Scrabble.Score("OXYPHENBUTAZONE")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Entire_alphabet() { - Assert.That(Scrabble.Score("abcdefghijklmnopqrstuvwxyz"), Is.EqualTo(87)); + Assert.Equal(87, Scrabble.Score("abcdefghijklmnopqrstuvwxyz")); } } \ No newline at end of file diff --git a/exercises/secret-handshake/SecretHandshakeTest.cs b/exercises/secret-handshake/SecretHandshakeTest.cs index e05498664a..ae79211060 100644 --- a/exercises/secret-handshake/SecretHandshakeTest.cs +++ b/exercises/secret-handshake/SecretHandshakeTest.cs @@ -1,53 +1,46 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class SecretHandshakeTests { - [Test] + [Fact] public void Test_1_handshake_to_wink() { - Assert.That(SecretHandshake.Commands(1), Is.EqualTo(new[] { "wink" })); + Assert.Equal(new[] { "wink" }, SecretHandshake.Commands(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_10_handshake_to_double_blink() { - Assert.That(SecretHandshake.Commands(2), Is.EqualTo(new[] { "double blink" })); + Assert.Equal(new[] { "double blink" }, SecretHandshake.Commands(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_100_handshake_to_close_your_eyes() { - Assert.That(SecretHandshake.Commands(4), Is.EqualTo(new[] { "close your eyes" })); + Assert.Equal(new[] { "close your eyes" }, SecretHandshake.Commands(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_1000_handshake_to_close_your_eyes() { - Assert.That(SecretHandshake.Commands(8), Is.EqualTo(new[] { "jump" })); + Assert.Equal(new[] { "jump" }, SecretHandshake.Commands(8)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_handshake_11_to_wink_and_double_blink() { - Assert.That(SecretHandshake.Commands(3), Is.EqualTo(new[] { "wink", "double blink" })); + Assert.Equal(new[] { "wink", "double blink" }, SecretHandshake.Commands(3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_handshake_10011_to_double_blink_and_wink() { - Assert.That(SecretHandshake.Commands(19), Is.EqualTo(new[] { "double blink", "wink" })); + Assert.Equal(new[] { "double blink", "wink" }, SecretHandshake.Commands(19)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Test_handshake_11111_to_all_commands_reversed() { - Assert.That(SecretHandshake.Commands(31), Is.EqualTo(new[] { "jump", "close your eyes", "double blink", "wink" })); + Assert.Equal(new[] { "jump", "close your eyes", "double blink", "wink" }, SecretHandshake.Commands(31)); } } diff --git a/exercises/series/SeriesTest.cs b/exercises/series/SeriesTest.cs index ba06103c96..17423b5419 100644 --- a/exercises/series/SeriesTest.cs +++ b/exercises/series/SeriesTest.cs @@ -1,79 +1,80 @@ -using NUnit.Framework; +using System; +using Xunit; -[TestFixture] public class SeriesTest { - private static readonly object[] SliceOneTestData = + public static readonly object[] SliceOneTestData = { new object[] { "01234", new[] { new[] { 0 }, new[] { 1 }, new[] { 2 }, new[] { 3 }, new[] { 4 } } }, new object[] { "92834", new[] { new[] { 9 }, new[] { 2 }, new[] { 8 }, new[] { 3 }, new[] { 4 } } } }; - [TestCaseSource("SliceOneTestData")] + [Theory] + [MemberData(nameof(SliceOneTestData))] public void Series_of_one_splits_to_one_digit(string input, int[][] result) { - Assert.That(new Series(input).Slices(1), Is.EqualTo(result)); + Assert.Equal(result, new Series(input).Slices(1)); } - private static readonly object[] SliceTwoTestData = + public static readonly object[] SliceTwoTestData = { new object[] { "01234", new[] { new[] { 0, 1 }, new[] { 1, 2 }, new[] { 2, 3 }, new[] { 3, 4 } } }, new object[] { "98273463", new[] { new[] { 9, 8 }, new[] { 8, 2 }, new[] { 2, 7 }, new[] { 7, 3 }, new[] { 3, 4 }, new[] { 4, 6 }, new[] { 6, 3 } } }, new object[] { "37103", new[] { new[] { 3, 7 }, new[] { 7, 1 }, new[] { 1, 0 }, new[] { 0, 3 } } } }; - [Ignore("Remove to run test")] - [TestCaseSource("SliceTwoTestData")] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(SliceTwoTestData))] public void Series_of_two_splits_to_two_digits(string input, int[][] result) { - Assert.That(new Series(input).Slices(2), Is.EqualTo(result)); + Assert.Equal(result, new Series(input).Slices(2)); } - private static readonly object[] SliceThreeTestData = + public static readonly object[] SliceThreeTestData = { new object[] { "01234", new[] { new[] { 0, 1, 2 }, new[] { 1, 2, 3 }, new[] { 2, 3, 4 } } }, new object[] { "31001", new[] { new[] { 3, 1, 0 }, new[] { 1, 0, 0 }, new[] { 0, 0, 1 } } }, new object[] { "982347", new[] { new[] { 9, 8, 2 }, new[] { 8, 2, 3 }, new[] { 2, 3, 4 }, new[] { 3, 4, 7 } } } }; - [Ignore("Remove to run test")] - [TestCaseSource("SliceThreeTestData")] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(SliceThreeTestData))] public void Series_of_three_splits_to_three_digits(string input, int[][] result) { - Assert.That(new Series(input).Slices(3), Is.EqualTo(result)); + Assert.Equal(result, new Series(input).Slices(3)); } - private static readonly object[] SliceFourTestData = + public static readonly object[] SliceFourTestData = { new object[] { "01234", new[] { new[] { 0, 1, 2, 3 }, new[] { 1, 2, 3, 4 } } }, new object[] { "91274", new[] { new[] { 9, 1, 2, 7 }, new[] { 1, 2, 7, 4 } } } }; - [Ignore("Remove to run test")] - [TestCaseSource("SliceFourTestData")] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(SliceFourTestData))] public void Series_of_four_splits_to_four_digits(string input, int[][] result) { - Assert.That(new Series(input).Slices(4), Is.EqualTo(result)); + Assert.Equal(result, new Series(input).Slices(4)); } - private static readonly object[] SliceFiveTestData = + public static readonly object[] SliceFiveTestData = { new object[] { "01234", new[] { new[] { 0, 1, 2, 3, 4 } } }, new object[] { "81228", new[] { new[] { 8, 1, 2, 2, 8 } } } }; - [Ignore("Remove to run test")] - [TestCaseSource("SliceFiveTestData")] + [Theory(Skip = "Remove to run test")] + [MemberData(nameof(SliceFiveTestData))] public void Series_of_five_splits_to_five_digits(string input, int[][] result) { - Assert.That(new Series(input).Slices(5), Is.EqualTo(result)); + Assert.Equal(result, new Series(input).Slices(5)); } - [Ignore("Remove to run test")] - [TestCase("01234", 6)] - [TestCase("01032987583", 19)] + [Theory(Skip = "Remove to run test")] + [InlineData("01234", 6)] + [InlineData("01032987583", 19)] public void Slice_longer_than_input_is_not_allowed(string input, int slice) { - Assert.That(() => new Series(input).Slices(slice), Throws.ArgumentException); + Assert.Throws(() => new Series(input).Slices(slice)); } } \ No newline at end of file diff --git a/exercises/sgf-parsing/Example.cs b/exercises/sgf-parsing/Example.cs index 800329ac73..e7b6a0ea84 100644 --- a/exercises/sgf-parsing/Example.cs +++ b/exercises/sgf-parsing/Example.cs @@ -34,7 +34,17 @@ private static Parser GameTree() => GameTree().Many().Then(trees => Parse.Char(')') .Select(___ => NodesToTree(nodes, trees))))); - public static SgfTree ParseTree(string input) => GameTree().Parse(input); + public static SgfTree ParseTree(string input) + { + try + { + return GameTree().Parse(input); + } + catch (Exception e) + { + throw new ArgumentException(nameof(input), e); + } + } private static SgfTree NodesToTree(IEnumerable> properties, IEnumerable trees) { diff --git a/exercises/sgf-parsing/SgfParsingTest.cs b/exercises/sgf-parsing/SgfParsingTest.cs index 9b695eb17f..958ff753a6 100644 --- a/exercises/sgf-parsing/SgfParsingTest.cs +++ b/exercises/sgf-parsing/SgfParsingTest.cs @@ -1,6 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; public class SgfParsingTest { @@ -20,82 +21,73 @@ public class SgfParsingTest private static IDictionary CreateData(string key, params string[] values) => new Dictionary { [key] = values }; - [Test] + [Fact] public void Empty_value() { const string input = ""; - Assert.That(() => SgfParser.ParseTree(input), Throws.Exception); + Assert.Throws(() => SgfParser.ParseTree(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Tree_without_nodes() { const string input = "()"; - Assert.That(() => SgfParser.ParseTree(input), Throws.Exception); + Assert.Throws(() => SgfParser.ParseTree(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Node_without_tree() { const string input = ";"; - Assert.That(() => SgfParser.ParseTree(input), Throws.Exception); + Assert.Throws(() => SgfParser.ParseTree(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Node_without_properties() { const string input = "(;)"; var expected = TreeWithNoChildren(new Dictionary()); - Assert.That(SgfParser.ParseTree(input), Is.EqualTo(expected).Using(SgfTreeEqualityComparer.Instance)); + Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Single_node_tree() { const string input = "(;A[B])"; var expected = TreeWithNoChildren(CreateData("A", "B")); - Assert.That(SgfParser.ParseTree(input), Is.EqualTo(expected).Using(SgfTreeEqualityComparer.Instance)); + Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Properties_without_delimiter() { const string input = "(;a)"; - Assert.That(() => SgfParser.ParseTree(input), Throws.Exception); + Assert.Throws(() => SgfParser.ParseTree(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void All_lowercase_property() { const string input = "(;a[b])"; - Assert.That(() => SgfParser.ParseTree(input), Throws.Exception); + Assert.Throws(() => SgfParser.ParseTree(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Upper_and_lowercase_property() { const string input = "(;Aa[b])"; - Assert.That(() => SgfParser.ParseTree(input), Throws.Exception); + Assert.Throws(() => SgfParser.ParseTree(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_nodes() { const string input = "(;A[B];B[C])"; var expected = TreeWithSingleChild(CreateData("A", "B"), TreeWithNoChildren(CreateData("B", "C"))); - Assert.That(SgfParser.ParseTree(input), Is.EqualTo(expected).Using(SgfTreeEqualityComparer.Instance)); + Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_child_trees() { const string input = "(;A[B](;B[C])(;C[D]))"; @@ -105,25 +97,23 @@ public void Two_child_trees() TreeWithNoChildren(CreateData("B", "C")), TreeWithNoChildren(CreateData("C", "D")) }); - Assert.That(SgfParser.ParseTree(input), Is.EqualTo(expected).Using(SgfTreeEqualityComparer.Instance)); + Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Multiple_properties() { const string input = "(;A[b][c][d])"; var expected = TreeWithNoChildren(CreateData("A", "b", "c", "d")); - Assert.That(SgfParser.ParseTree(input), Is.EqualTo(expected).Using(SgfTreeEqualityComparer.Instance)); + Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Escaped_property() { const string input = @"(;A[\]b\nc\nd\t\te \n\]])"; var expected = TreeWithNoChildren(CreateData("A", @"]b c d e ]")); - Assert.That(SgfParser.ParseTree(input), Is.EqualTo(expected).Using(SgfTreeEqualityComparer.Instance)); + Assert.Equal(expected, SgfParser.ParseTree(input), SgfTreeEqualityComparer.Instance); } private class SgfTreeEqualityComparer : IEqualityComparer diff --git a/exercises/sieve/SieveTest.cs b/exercises/sieve/SieveTest.cs index 8b24539c6f..363232b08a 100644 --- a/exercises/sieve/SieveTest.cs +++ b/exercises/sieve/SieveTest.cs @@ -1,27 +1,23 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class SieveTest { - [Test] + [Fact] public void Finds_first_prime() { - Assert.That(Sieve.Primes(2), Is.EqualTo(new[] { 2 })); + Assert.Equal(new[] { 2 }, Sieve.Primes(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Finds_primes_up_to_10() { - Assert.That(Sieve.Primes(10), Is.EqualTo(new[] { 2, 3, 5, 7 })); + Assert.Equal(new[] { 2, 3, 5, 7 }, Sieve.Primes(10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Finds_primes_up_to_1000() { - Assert.That(Sieve.Primes(1000), - Is.EqualTo(new[] + Assert.Equal(new[] { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, @@ -32,6 +28,6 @@ public void Finds_primes_up_to_1000() 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 - })); + }, Sieve.Primes(1000)); } } \ No newline at end of file diff --git a/exercises/simple-cipher/SimpleCipherTest.cs b/exercises/simple-cipher/SimpleCipherTest.cs index 6afc801194..cc13230826 100644 --- a/exercises/simple-cipher/SimpleCipherTest.cs +++ b/exercises/simple-cipher/SimpleCipherTest.cs @@ -1,169 +1,138 @@ -using NUnit.Framework; +using System; +using Xunit; -[TestFixture] public class RandomKeyCipherTest { - private Cipher cipher; + private readonly Cipher cipher = new Cipher(); - [SetUp] - public void Setup() - { - cipher = new Cipher(); - } - - [Test] + [Fact] public void Cipher_key_is_made_of_letters() { - Assert.That(cipher.Key, Does.Match("[a-z]+")); + Assert.Matches("[a-z]+", cipher.Key); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Default_cipher_key_is_100_characters() { - Assert.That(cipher.Key, Has.Length.EqualTo(100)); + Assert.Equal(100, cipher.Key.Length); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_keys_are_randomly_generated() { - Assert.That(cipher.Key, Is.Not.EqualTo(new Cipher().Key)); + Assert.NotEqual(new Cipher().Key, cipher.Key); } // Here we take advantage of the fact that plaintext of "aaa..." doesn't output // the key. This is a critical problem with shift ciphers, some characters // will always output the key verbatim. - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_encode() { - Assert.That(cipher.Encode("aaaaaaaaaa"), Is.EqualTo(cipher.Key.Substring(0, 10))); + Assert.Equal(cipher.Key.Substring(0, 10), cipher.Encode("aaaaaaaaaa")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_decode() { - Assert.That(cipher.Decode(cipher.Key.Substring(0, 10)), Is.EqualTo("aaaaaaaaaa")); + Assert.Equal("aaaaaaaaaa", cipher.Decode(cipher.Key.Substring(0, 10))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_is_reversible() { const string PLAINTEXT = "abcdefghij"; - Assert.That(cipher.Decode(cipher.Encode(PLAINTEXT)), Is.EqualTo(PLAINTEXT)); + Assert.Equal(PLAINTEXT, cipher.Decode(cipher.Encode(PLAINTEXT))); } } -[TestFixture] + public class IncorrectKeyCipherTest { - [Ignore("Remove to run test")] - [Test] + [Fact] public void Cipher_throws_with_an_all_caps_key() { - Assert.That(() => new Cipher("ABCDEF"), Throws.ArgumentException); + Assert.Throws(() => new Cipher("ABCDEF")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_throws_with_any_caps_key() { - Assert.That(() => new Cipher("abcdEFg"), Throws.ArgumentException); + Assert.Throws(() => new Cipher("abcdEFg")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_throws_with_numeric_key() { - Assert.That(() => new Cipher("12345"), Throws.ArgumentException); + Assert.Throws(() => new Cipher("12345")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_throws_with_any_numeric_key() { - Assert.That(() => new Cipher("abcd345ef"), Throws.ArgumentException); + Assert.Throws(() => new Cipher("abcd345ef")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_throws_with_empty_key() { - Assert.That(() => new Cipher(""), Throws.ArgumentException); + Assert.Throws(() => new Cipher("")); } } -[TestFixture] + public class SubstitutionCipherTest { private const string KEY = "abcdefghij"; - private Cipher cipher; - - [Ignore("Remove to run test")] - [SetUp] - public void Setup() - { - cipher = new Cipher(KEY); - } + private readonly Cipher cipher = new Cipher(KEY); - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_keeps_the_submitted_key() { - Assert.That(cipher.Key, Is.EqualTo(KEY)); + Assert.Equal(KEY, cipher.Key); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_encode_with_given_key() { - Assert.That(cipher.Encode("aaaaaaaaaa"), Is.EqualTo("abcdefghij")); + Assert.Equal("abcdefghij", cipher.Encode("aaaaaaaaaa")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_decode_with_given_key() { - Assert.That(cipher.Decode("abcdefghij"), Is.EqualTo("aaaaaaaaaa")); + Assert.Equal("aaaaaaaaaa", cipher.Decode("abcdefghij")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_is_reversible_given_key() { const string PLAINTEXT = "abcdefghij"; - Assert.That(cipher.Decode(cipher.Encode(PLAINTEXT)), Is.EqualTo(PLAINTEXT)); + Assert.Equal(PLAINTEXT, cipher.Decode(cipher.Encode(PLAINTEXT))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_double_shift_encode() { const string PLAINTEXT = "iamapandabear"; - Assert.That(new Cipher(PLAINTEXT).Encode(PLAINTEXT), Is.EqualTo("qayaeaagaciai")); + Assert.Equal("qayaeaagaciai", new Cipher(PLAINTEXT).Encode(PLAINTEXT)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_wrap_encode() { - Assert.That(cipher.Encode("zzzzzzzzzz"), Is.EqualTo("zabcdefghi")); + Assert.Equal("zabcdefghi", cipher.Encode("zzzzzzzzzz")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_encode_a_message_that_is_shorter_than_the_key() { - Assert.That(cipher.Encode("aaaaa"), Is.EqualTo("abcde")); + Assert.Equal("abcde", cipher.Encode("aaaaa")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cipher_can_decode_a_message_that_is_shorter_than_the_key() { - Assert.That(cipher.Decode("abcde"), Is.EqualTo("aaaaa")); + Assert.Equal("aaaaa", cipher.Decode("abcde")); } } \ No newline at end of file diff --git a/exercises/simple-linked-list/SimpleLinkedListTest.cs b/exercises/simple-linked-list/SimpleLinkedListTest.cs index 802fd1d93c..293f11daa4 100644 --- a/exercises/simple-linked-list/SimpleLinkedListTest.cs +++ b/exercises/simple-linked-list/SimpleLinkedListTest.cs @@ -1,87 +1,83 @@ using System.Linq; -using NUnit.Framework; +using Xunit; public class SimpleLinkedListTest { - [Test] + [Fact] public void Single_item_list_value() { var list = new SimpleLinkedList(1); - Assert.That(list.Value, Is.EqualTo(1)); + Assert.Equal(1, list.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Single_item_list_has_no_next_item() { var list = new SimpleLinkedList(1); - Assert.That(list.Next, Is.Null); + Assert.Null(list.Next); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_item_list_first_value() { var list = new SimpleLinkedList(2).Add(1); - Assert.That(list.Value, Is.EqualTo(2)); + Assert.Equal(2, list.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_item_list_second_value() { var list = new SimpleLinkedList(2).Add(1); - Assert.That(list.Next.Value, Is.EqualTo(1)); + Assert.Equal(1, list.Next.Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_item_list_second_item_has_no_next() { var list = new SimpleLinkedList(2).Add(1); - Assert.That(list.Next.Next, Is.Null); + Assert.Null(list.Next.Next); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Implements_enumerable() { var values = new SimpleLinkedList(2).Add(1); - Assert.That(values, Is.EqualTo(new[] { 2, 1 })); + Assert.Equal(new[] { 2, 1 }, values); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void From_enumerable() { var list = new SimpleLinkedList(new[] { 11, 7, 5, 3, 2 }); - Assert.That(list.Value, Is.EqualTo(11)); - Assert.That(list.Next.Value, Is.EqualTo(7)); - Assert.That(list.Next.Next.Value, Is.EqualTo(5)); - Assert.That(list.Next.Next.Next.Value, Is.EqualTo(3)); - Assert.That(list.Next.Next.Next.Next.Value, Is.EqualTo(2)); + Assert.Equal(11, list.Value); + Assert.Equal(7, list.Next.Value); + Assert.Equal(5, list.Next.Next.Value); + Assert.Equal(3, list.Next.Next.Next.Value); + Assert.Equal(2, list.Next.Next.Next.Next.Value); } - [TestCase(1, Ignore = "Remove to run test case")] - [TestCase(2, Ignore = "Remove to run test case")] - [TestCase(10, Ignore = "Remove to run test case")] - [TestCase(100, Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData(1)] + [InlineData(2)] + [InlineData(10)] + [InlineData(100)] public void Reverse(int length) { var values = Enumerable.Range(1, length).ToArray(); var list = new SimpleLinkedList(values); var reversed = list.Reverse(); - Assert.That(reversed, Is.EqualTo(values.Reverse())); + Assert.Equal(values.Reverse(), reversed); } - [TestCase(1, Ignore = "Remove to run test case")] - [TestCase(2, Ignore = "Remove to run test case")] - [TestCase(10, Ignore = "Remove to run test case")] - [TestCase(100, Ignore = "Remove to run test case")] + [Theory(Skip = "Remove to run test")] + [InlineData(1)] + [InlineData(2)] + [InlineData(10)] + [InlineData(100)] public void Roundtrip(int length) { var values = Enumerable.Range(1, length); var listValues = new SimpleLinkedList(values); - Assert.That(listValues, Is.EqualTo(values)); + Assert.Equal(values, listValues); } } \ No newline at end of file diff --git a/exercises/space-age/Example.cs b/exercises/space-age/Example.cs index dc81fb6022..7bb1aa570c 100644 --- a/exercises/space-age/Example.cs +++ b/exercises/space-age/Example.cs @@ -10,16 +10,16 @@ private enum Planet public long Seconds { get; private set; } - private readonly Dictionary earthYearToPlanetPeriod = new Dictionary + private readonly Dictionary earthYearToPlanetPeriod = new Dictionary { { Planet.Earth, 1 }, - { Planet.Mercury, 0.2408467m }, - { Planet.Venus, 0.61519726m }, - { Planet.Mars, 1.8808158m }, - { Planet.Jupiter, 11.862615m }, - { Planet.Saturn, 29.447498m }, - { Planet.Uranus, 84.016846m }, - { Planet.Neptune, 164.79132m }, + { Planet.Mercury, 0.2408467 }, + { Planet.Venus, 0.61519726 }, + { Planet.Mars, 1.8808158 }, + { Planet.Jupiter, 11.862615 }, + { Planet.Saturn, 29.447498 }, + { Planet.Uranus, 84.016846 }, + { Planet.Neptune, 164.79132 }, }; public SpaceAge(long seconds) @@ -27,48 +27,48 @@ public SpaceAge(long seconds) Seconds = seconds; } - private decimal CalculateAge(decimal periodInEarthYears) + private double CalculateAge(double periodInEarthYears) { - const decimal EARTH_ORBIT_IN_SECONDS = 31557600; + const double EARTH_ORBIT_IN_SECONDS = 31557600; return Math.Round(Seconds / (EARTH_ORBIT_IN_SECONDS * periodInEarthYears), 2); } - public decimal OnEarth() + public double OnEarth() { return CalculateAge(earthYearToPlanetPeriod[Planet.Earth]); } - public decimal OnMercury() + public double OnMercury() { return CalculateAge(earthYearToPlanetPeriod[Planet.Mercury]); } - public decimal OnVenus() + public double OnVenus() { return CalculateAge(earthYearToPlanetPeriod[Planet.Venus]); } - public decimal OnMars() + public double OnMars() { return CalculateAge(earthYearToPlanetPeriod[Planet.Mars]); } - public decimal OnJupiter() + public double OnJupiter() { return CalculateAge(earthYearToPlanetPeriod[Planet.Jupiter]); } - public decimal OnSaturn() + public double OnSaturn() { return CalculateAge(earthYearToPlanetPeriod[Planet.Saturn]); } - public decimal OnUranus() + public double OnUranus() { return CalculateAge(earthYearToPlanetPeriod[Planet.Uranus]); } - public decimal OnNeptune() + public double OnNeptune() { return CalculateAge(earthYearToPlanetPeriod[Planet.Neptune]); } diff --git a/exercises/space-age/SpaceAgeTest.cs b/exercises/space-age/SpaceAgeTest.cs index 38b6f093b6..09cee31cc3 100644 --- a/exercises/space-age/SpaceAgeTest.cs +++ b/exercises/space-age/SpaceAgeTest.cs @@ -1,84 +1,74 @@ +using Xunit; -using NUnit.Framework; - -[TestFixture] public class SpaceAgeTest { - [Test] + [Fact] public void Age_in_seconds() { var age = new SpaceAge(1000000); - Assert.That(age.Seconds, Is.EqualTo(1000000)); + Assert.Equal(1000000, age.Seconds); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_earth() { var age = new SpaceAge(1000000000); - Assert.That(age.OnEarth(), Is.EqualTo(31.69).Within(1E-02)); + Assert.Equal(31.69, age.OnEarth()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_mercury() { var age = new SpaceAge(2134835688); - Assert.That(age.OnEarth(), Is.EqualTo(67.65).Within(1E-02)); - Assert.That(age.OnMercury(), Is.EqualTo(280.88).Within(1E-02)); + Assert.Equal(67.65, age.OnEarth()); + Assert.Equal(280.88, age.OnMercury()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_venus() { var age = new SpaceAge(189839836); - Assert.That(age.OnEarth(), Is.EqualTo(6.02).Within(1E-02)); - Assert.That(age.OnVenus(), Is.EqualTo(9.78).Within(1E-02)); + Assert.Equal(6.02, age.OnEarth()); + Assert.Equal(9.78, age.OnVenus()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_mars() { var age = new SpaceAge(2329871239); - Assert.That(age.OnEarth(), Is.EqualTo(73.83).Within(1E-02)); - Assert.That(age.OnMars(), Is.EqualTo(39.25).Within(1E-02)); + Assert.Equal(73.83, age.OnEarth()); + Assert.Equal(39.25, age.OnMars()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_jupiter() { var age = new SpaceAge(901876382); - Assert.That(age.OnEarth(), Is.EqualTo(28.58).Within(1E-02)); - Assert.That(age.OnJupiter(), Is.EqualTo(2.41).Within(1E-02)); + Assert.Equal(28.58, age.OnEarth()); + Assert.Equal(2.41, age.OnJupiter()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_saturn() { var age = new SpaceAge(3000000000); - Assert.That(age.OnEarth(), Is.EqualTo(95.06).Within(1E-02)); - Assert.That(age.OnSaturn(), Is.EqualTo(3.23).Within(1E-02)); + Assert.Equal(95.06, age.OnEarth()); + Assert.Equal(3.23, age.OnSaturn()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_uranus() { var age = new SpaceAge(3210123456); - Assert.That(age.OnEarth(), Is.EqualTo(101.72).Within(1E-02)); - Assert.That(age.OnUranus(), Is.EqualTo(1.21).Within(1E-02)); + Assert.Equal(101.72, age.OnEarth()); + Assert.Equal(1.21, age.OnUranus()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Age_on_neptune() { var age = new SpaceAge(8210123456); - Assert.That(age.OnEarth(), Is.EqualTo(260.16).Within(1E-02)); - Assert.That(age.OnNeptune(), Is.EqualTo(1.58).Within(1E-02)); + Assert.Equal(260.16, age.OnEarth()); + Assert.Equal(1.58, age.OnNeptune()); } } \ No newline at end of file diff --git a/exercises/strain/StrainTest.cs b/exercises/strain/StrainTest.cs index 621b00bd93..6a91e8b2c9 100644 --- a/exercises/strain/StrainTest.cs +++ b/exercises/strain/StrainTest.cs @@ -1,47 +1,41 @@ using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; -[TestFixture] public class StrainTest { - [Test] + [Fact] public void Empty_keep() { - Assert.That(new LinkedList().Keep(x => x < 10), Is.EqualTo(new LinkedList())); + Assert.Equal(new LinkedList(), new LinkedList().Keep(x => x < 10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Keep_everything() { - Assert.That(new HashSet { 1, 2, 3 }.Keep(x => x < 10), Is.EqualTo(new HashSet { 1, 2, 3 })); + Assert.Equal(new HashSet { 1, 2, 3 }, new HashSet { 1, 2, 3 }.Keep(x => x < 10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Keep_first_and_last() { - Assert.That(new[] { 1, 2, 3 }.Keep(x => x % 2 != 0), Is.EqualTo(new[] { 1, 3 })); + Assert.Equal(new[] { 1, 3 }, new[] { 1, 2, 3 }.Keep(x => x % 2 != 0)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Keep_neither_first_nor_last() { - Assert.That(new List { 1, 2, 3, 4, 5 }.Keep(x => x % 2 == 0), Is.EqualTo(new List { 2, 4 })); + Assert.Equal(new List { 2, 4 }, new List { 1, 2, 3, 4, 5 }.Keep(x => x % 2 == 0)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Keep_strings() { var words = "apple zebra banana zombies cherimoya zelot".Split(' '); - Assert.That(words.Keep(x => x.StartsWith("z")), Is.EqualTo("zebra zombies zelot".Split(' '))); + Assert.Equal("zebra zombies zelot".Split(' '), words.Keep(x => x.StartsWith("z"))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Keep_arrays() { var actual = new[] @@ -55,47 +49,41 @@ public void Keep_arrays() new[] { 1, 2, 5 } }; var expected = new[] { new[] { 5, 5, 5 }, new[] { 5, 1, 2 }, new[] { 1, 5, 2 }, new[] { 1, 2, 5 } }; - Assert.That(actual.Keep(x => x.Contains(5)), Is.EqualTo(expected)); + Assert.Equal(expected, actual.Keep(x => x.Contains(5))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_discard() { - Assert.That(new LinkedList().Discard(x => x < 10), Is.EqualTo(new LinkedList())); + Assert.Equal(new LinkedList(), new LinkedList().Discard(x => x < 10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Discard_nothing() { - Assert.That(new HashSet { 1, 2, 3 }.Discard(x => x > 10), Is.EqualTo(new HashSet { 1, 2, 3 })); + Assert.Equal(new HashSet { 1, 2, 3 }, new HashSet { 1, 2, 3 }.Discard(x => x > 10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Discard_first_and_last() { - Assert.That(new[] { 1, 2, 3 }.Discard(x => x % 2 != 0), Is.EqualTo(new[] { 2 })); + Assert.Equal(new[] { 2 }, new[] { 1, 2, 3 }.Discard(x => x % 2 != 0)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Discard_neither_first_nor_last() { - Assert.That(new List { 1, 2, 3, 4, 5 }.Discard(x => x % 2 == 0), Is.EqualTo(new List { 1, 3, 5 })); + Assert.Equal(new List { 1, 3, 5 }, new List { 1, 2, 3, 4, 5 }.Discard(x => x % 2 == 0)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Discard_strings() { var words = "apple zebra banana zombies cherimoya zelot".Split(' '); - Assert.That(words.Discard(x => x.StartsWith("z")), Is.EqualTo("apple banana cherimoya".Split(' '))); + Assert.Equal("apple banana cherimoya".Split(' '), words.Discard(x => x.StartsWith("z"))); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Discard_arrays() { var actual = new[] @@ -109,6 +97,6 @@ public void Discard_arrays() new[] { 1, 2, 5 } }; var expected = new[] { new[] { 1, 2, 3 }, new[] { 2, 1, 2 }, new[] { 2, 2, 1 } }; - Assert.That(actual.Discard(x => x.Contains(5)), Is.EqualTo(expected)); + Assert.Equal(expected, actual.Discard(x => x.Contains(5))); } } \ No newline at end of file diff --git a/exercises/sublist/SublistTest.cs b/exercises/sublist/SublistTest.cs index b13e40f3bc..f777937a8c 100644 --- a/exercises/sublist/SublistTest.cs +++ b/exercises/sublist/SublistTest.cs @@ -1,167 +1,150 @@ using System.Collections.Generic; using System.Linq; -using NUnit.Framework; +using Xunit; public class SublistTest { - [Test] + [Fact] public void Empty_equals_empty() { var list1 = new List(); var list2 = new List(); - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Equal)); + Assert.Equal(SublistType.Equal, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_is_a_sublist_of_anything() { var list1 = new List(); var list2 = new List { 1, 2, 3, 4 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Anything_is_a_superlist_of_empty() { var list1 = new List { 1, 2, 3, 4 }; var list2 = new List(); - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Superlist)); + Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void One_is_not_two() { var list1 = new List { 1 }; var list2 = new List { 2 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Unequal)); + Assert.Equal(SublistType.Unequal, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Compare_larger_equal_lists() { var list1 = new List(Enumerable.Repeat('x', 1000)); var list2 = new List(Enumerable.Repeat('x', 1000)); - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Equal)); + Assert.Equal(SublistType.Equal, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sublist_at_start() { var list1 = new List { 1, 2, 3 }; var list2 = new List { 1, 2, 3, 4, 5 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sublist_in_middle() { var list1 = new List { 4, 3, 2 }; var list2 = new List { 5, 4, 3, 2, 1 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sublist_at_end() { var list1 = new List { 3, 4, 5 }; var list2 = new List { 1, 2, 3, 4, 5 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Partially_matching_sublist_at_start() { var list1 = new List { 1, 1, 2 }; var list2 = new List { 1, 1, 1, 2 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sublist_early_in_huge_list() { var list1 = new List { 3, 4, 5 }; var list2 = new List(Enumerable.Range(1, 1000000)); - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Huge_sublist_not_in_huge_list() { var list1 = new List(Enumerable.Range(10, 1000001)); var list2 = new List(Enumerable.Range(1, 1000000)); - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Unequal)); + Assert.Equal(SublistType.Unequal, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Superlist_at_start() { var list1 = new List { 1, 2, 3, 4, 5 }; var list2 = new List { 1, 2, 3 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Superlist)); + Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Superlist_in_middle() { var list1 = new List { 5, 4, 3, 2, 1 }; var list2 = new List { 4, 3, 2 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Superlist)); + Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Superlist_at_end() { var list1 = new List { 1, 2, 3, 4, 5 }; var list2 = new List { 3, 4, 5 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Superlist)); + Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Partially_matching_superlist_at_start() { var list1 = new List { 1, 1, 1, 2 }; var list2 = new List { 1, 1, 2 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Superlist)); + Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Superlist_early_in_huge_list() { var list1 = new List(Enumerable.Range(1, 1000000)); var list2 = new List { 3, 4, 5 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Superlist)); + Assert.Equal(SublistType.Superlist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recurring_values_sublist() { var list1 = new List { 1, 2, 1, 2, 3 }; var list2 = new List { 1, 2, 3, 1, 2, 1, 2, 3, 2, 1 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Sublist)); + Assert.Equal(SublistType.Sublist, Sublist.Classify(list1, list2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Recurring_values_unequal() { var list1 = new List { 1, 2, 1, 2, 3 }; var list2 = new List { 1, 2, 3, 1, 2, 3, 2, 3, 2, 1 }; - Assert.That(Sublist.Classify(list1, list2), Is.EqualTo(SublistType.Unequal)); + Assert.Equal(SublistType.Unequal, Sublist.Classify(list1, list2)); } } \ No newline at end of file diff --git a/exercises/sum-of-multiples/SumOfMultiplesTest.cs b/exercises/sum-of-multiples/SumOfMultiplesTest.cs index db2b6f2553..cb6c31fe64 100644 --- a/exercises/sum-of-multiples/SumOfMultiplesTest.cs +++ b/exercises/sum-of-multiples/SumOfMultiplesTest.cs @@ -1,53 +1,46 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class SumOfMultiplesTest { - [Test] + [Fact] public void Sum_to_1() { - Assert.That(SumOfMultiples.To(new[] { 3, 5 }, 1), Is.EqualTo(0)); + Assert.Equal(0, SumOfMultiples.To(new[] { 3, 5 }, 1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sum_to_3() { - Assert.That(SumOfMultiples.To(new[] { 3, 5 }, 4), Is.EqualTo(3)); + Assert.Equal(3, SumOfMultiples.To(new[] { 3, 5 }, 4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sum_to_10() { - Assert.That(SumOfMultiples.To(new[] { 3, 5 }, 10), Is.EqualTo(23)); + Assert.Equal(23, SumOfMultiples.To(new[] { 3, 5 }, 10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sum_to_100() { - Assert.That(SumOfMultiples.To(new[] { 3, 5 }, 100), Is.EqualTo(2318)); + Assert.Equal(2318, SumOfMultiples.To(new[] { 3, 5 }, 100)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sum_to_1000() { - Assert.That(SumOfMultiples.To(new[] { 3, 5 }, 1000), Is.EqualTo(233168)); + Assert.Equal(233168, SumOfMultiples.To(new[] { 3, 5 }, 1000)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sum_to_20() { - Assert.That(SumOfMultiples.To(new [] { 7, 13, 17 }, 20), Is.EqualTo(51)); + Assert.Equal(51, SumOfMultiples.To(new [] { 7, 13, 17 }, 20)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Sum_to_10000() { - Assert.That(SumOfMultiples.To(new [] { 43, 47 }, 10000), Is.EqualTo(2203160)); + Assert.Equal(2203160, SumOfMultiples.To(new [] { 43, 47 }, 10000)); } } diff --git a/exercises/tournament/TournamentTest.cs b/exercises/tournament/TournamentTest.cs index 6daa4a92f6..9cde95fa87 100644 --- a/exercises/tournament/TournamentTest.cs +++ b/exercises/tournament/TournamentTest.cs @@ -1,9 +1,8 @@ using System; using System.IO; using System.Text; -using NUnit.Framework; +using Xunit; -[TestFixture] public class TournamentTest { readonly string input1 = @@ -68,23 +67,21 @@ private string RunTally(string input) } } - [Test] + [Fact] public void Test_good() { - Assert.That(RunTally(input1).Trim(), Is.EqualTo(expected1)); + Assert.Equal(expected1, RunTally(input1).Trim()); } - - [Test] - [Ignore("Remove to run test")] + + [Fact(Skip = "Remove to run test")] public void Test_ignore_bad_lines() { - Assert.That(RunTally(input2).Trim(), Is.EqualTo(expected2)); + Assert.Equal(expected2, RunTally(input2).Trim()); } - - [Test] - [Ignore("Remove to run test")] + + [Fact(Skip = "Remove to run test")] public void Test_incomplete_competition() { - Assert.That(RunTally(input3).Trim(), Is.EqualTo(expected3)); + Assert.Equal(expected3, RunTally(input3).Trim()); } } diff --git a/exercises/transpose/TransposeTest.cs b/exercises/transpose/TransposeTest.cs index c039b85581..23ff1813d9 100644 --- a/exercises/transpose/TransposeTest.cs +++ b/exercises/transpose/TransposeTest.cs @@ -1,18 +1,17 @@ -using NUnit.Framework; +using Xunit; public class TransposeTest { - [Test] + [Fact] public void Empty_string() { const string input = ""; const string expected = ""; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Two_characters() { const string input = @@ -22,11 +21,10 @@ public void Two_characters() "A\n" + "1"; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Simple() { const string input = @@ -38,11 +36,10 @@ public void Simple() "B2\n" + "C3"; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Single_line() { const string input = @@ -62,11 +59,10 @@ public void Single_line() "e\n" + "."; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void First_line_longer_than_second_line() { const string input = @@ -91,11 +87,10 @@ public void First_line_longer_than_second_line() "e.\n" + "."; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Second_line_longer_than_first_line() { const string input = @@ -120,11 +115,10 @@ public void Second_line_longer_than_first_line() ".e\n" + " ."; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Square() { const string input = @@ -141,11 +135,10 @@ public void Square() "RESIN\n" + "TREND"; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Test] - [Ignore("Remove to run test")] + [Fact(Skip = "Remove to run test")] public void Rectangle() { const string input = @@ -164,11 +157,10 @@ public void Rectangle() "RENT\n" + "EDGE"; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Triangle() { const string input = @@ -187,11 +179,10 @@ public void Triangle() " ER\n" + " R"; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Many_lines() { const string input = @@ -266,6 +257,6 @@ public void Many_lines() " , "; - Assert.That(Transpose.String(input), Is.EqualTo(expected)); + Assert.Equal(expected, Transpose.String(input)); } } \ No newline at end of file diff --git a/exercises/tree-building/TreeBuildingTest.cs b/exercises/tree-building/TreeBuildingTest.cs index 254c9ba7f1..d3d7016732 100644 --- a/exercises/tree-building/TreeBuildingTest.cs +++ b/exercises/tree-building/TreeBuildingTest.cs @@ -1,8 +1,9 @@ -using NUnit.Framework; +using System; +using Xunit; public class TreeBuildingTest { - [Test] + [Fact] public void One_node() { var records = new[] @@ -15,7 +16,7 @@ public void One_node() AssertTreeIsLeaf(tree, id: 0); } - [Test] + [Fact(Skip = "Remove to run test")] public void Three_nodes_in_order() { var records = new[] @@ -32,7 +33,7 @@ public void Three_nodes_in_order() AssertTreeIsLeaf(tree.Children[1], id: 2); } - [Test] + [Fact(Skip = "Remove to run test")] public void Three_nodes_in_reverse_order() { var records = new[] @@ -49,7 +50,7 @@ public void Three_nodes_in_reverse_order() AssertTreeIsLeaf(tree.Children[1], id: 2); } - [Test] + [Fact(Skip = "Remove to run test")] public void More_than_two_children() { var records = new[] @@ -68,7 +69,7 @@ public void More_than_two_children() AssertTreeIsLeaf(tree.Children[2], id: 3); } - [Test] + [Fact(Skip = "Remove to run test")] public void Binary_tree() { var records = new[] @@ -94,7 +95,7 @@ public void Binary_tree() AssertTreeIsLeaf(tree.Children[1].Children[1], id: 6); } - [Test] + [Fact(Skip = "Remove to run test")] public void Unbalanced_tree() { var records = new[] @@ -120,15 +121,15 @@ public void Unbalanced_tree() AssertTreeIsLeaf(tree.Children[1].Children[2], id: 6); } - [Test] + [Fact(Skip = "Remove to run test")] public void Empty_input() { var records = new TreeBuildingRecord[0]; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Root_node_has_parent() { var records = new[] @@ -137,10 +138,10 @@ public void Root_node_has_parent() new TreeBuildingRecord { RecordId = 1, ParentId = 0 } }; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } - [Test] + [Fact(Skip = "Remove to run test")] public void No_root_node() { var records = new[] @@ -148,11 +149,11 @@ public void No_root_node() new TreeBuildingRecord { RecordId = 1, ParentId = 0 } }; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Non_continuous() { var records = new[] @@ -163,10 +164,10 @@ public void Non_continuous() new TreeBuildingRecord { RecordId = 0, ParentId = 0 } }; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Cycle_directly() { var records = new[] @@ -180,10 +181,10 @@ public void Cycle_directly() new TreeBuildingRecord { RecordId = 6, ParentId = 3 } }; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Cycle_indirectly() { var records = new[] @@ -197,10 +198,10 @@ public void Cycle_indirectly() new TreeBuildingRecord { RecordId = 6, ParentId = 3 } }; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } - [Test] + [Fact(Skip = "Remove to run test")] public void Higher_id_parent_of_lower_id() { var records = new[] @@ -210,19 +211,19 @@ public void Higher_id_parent_of_lower_id() new TreeBuildingRecord { RecordId = 1, ParentId = 2 } }; - Assert.That(() => TreeBuilder.BuildTree(records), Throws.Exception); + Assert.Throws(() => TreeBuilder.BuildTree(records)); } private static void AssertTreeIsBranch(Tree tree, int id, int childCount) { - Assert.That(tree.Id, Is.EqualTo(id)); - Assert.That(tree.IsLeaf, Is.False); - Assert.That(tree.Children.Count, Is.EqualTo(childCount)); + Assert.Equal(id, tree.Id); + Assert.False(tree.IsLeaf); + Assert.Equal(childCount, tree.Children.Count); } private static void AssertTreeIsLeaf(Tree tree, int id) { - Assert.That(tree.Id, Is.EqualTo(id)); - Assert.That(tree.IsLeaf, Is.True); + Assert.Equal(id, tree.Id); + Assert.True(tree.IsLeaf); } } \ No newline at end of file diff --git a/exercises/triangle/TriangleTest.cs b/exercises/triangle/TriangleTest.cs index 61a6d8be83..b8457c6379 100644 --- a/exercises/triangle/TriangleTest.cs +++ b/exercises/triangle/TriangleTest.cs @@ -1,107 +1,92 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class TriangleTest { - [Test] + [Fact] public void Equilateral_triangles_have_equal_sides() { - Assert.That(Triangle.Kind(2, 2, 2), Is.EqualTo(TriangleKind.Equilateral)); + Assert.Equal(TriangleKind.Equilateral, Triangle.Kind(2, 2, 2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Larger_equilateral_triangles_also_have_equal_sides() { - Assert.That(Triangle.Kind(10, 10, 10), Is.EqualTo(TriangleKind.Equilateral)); + Assert.Equal(TriangleKind.Equilateral, Triangle.Kind(10, 10, 10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Isosceles_triangles_have_last_two_sides_equal() { - Assert.That(Triangle.Kind(3, 4, 4), Is.EqualTo(TriangleKind.Isosceles)); + Assert.Equal(TriangleKind.Isosceles, Triangle.Kind(3, 4, 4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Isosceles_triangles_have_first_and_last_sides_equal() { - Assert.That(Triangle.Kind(4, 3, 4), Is.EqualTo(TriangleKind.Isosceles)); + Assert.Equal(TriangleKind.Isosceles, Triangle.Kind(4, 3, 4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Isosceles_triangles_have_two_first_sides_equal() { - Assert.That(Triangle.Kind(4, 4, 3), Is.EqualTo(TriangleKind.Isosceles)); + Assert.Equal(TriangleKind.Isosceles, Triangle.Kind(4, 4, 3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Isosceles_triangles_have_in_fact_exactly_two_sides_equal() { - Assert.That(Triangle.Kind(10, 10, 2), Is.EqualTo(TriangleKind.Isosceles)); + Assert.Equal(TriangleKind.Isosceles, Triangle.Kind(10, 10, 2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Scalene_triangles_have_no_equal_sides() { - Assert.That(Triangle.Kind(3, 4, 5), Is.EqualTo(TriangleKind.Scalene)); + Assert.Equal(TriangleKind.Scalene, Triangle.Kind(3, 4, 5)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Scalene_triangles_have_no_equal_sides_at_a_larger_scale_too() { - Assert.That(Triangle.Kind(10, 11, 12), Is.EqualTo(TriangleKind.Scalene)); + Assert.Equal(TriangleKind.Scalene, Triangle.Kind(10, 11, 12)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Scalene_triangles_have_no_equal_sides_in_descending_order_either() { - Assert.That(Triangle.Kind(5, 4, 2), Is.EqualTo(TriangleKind.Scalene)); + Assert.Equal(TriangleKind.Scalene, Triangle.Kind(5, 4, 2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Very_small_triangles_are_legal() { - Assert.That(Triangle.Kind(0.4m, 0.6m, 0.3m), Is.EqualTo(TriangleKind.Scalene)); + Assert.Equal(TriangleKind.Scalene, Triangle.Kind(0.4m, 0.6m, 0.3m)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Triangles_with_no_size_are_illegal() { Assert.Throws(() => Triangle.Kind(0, 0, 0)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Triangles_with_negative_sides_are_illegal() { Assert.Throws(() => Triangle.Kind(3, 4, -5)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Triangles_violating_triangle_inequality_are_illegal() { Assert.Throws(() => Triangle.Kind(1, 1, 3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Triangles_violating_triangle_inequality_are_illegal_2() { Assert.Throws(() => Triangle.Kind(2, 4, 2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Triangles_violating_triangle_inequality_are_illegal_3() { Assert.Throws(() => Triangle.Kind(7, 3, 2)); diff --git a/exercises/twelve-days/TwelveDaysTest.cs b/exercises/twelve-days/TwelveDaysTest.cs index e8830e92c3..ebbb104a35 100644 --- a/exercises/twelve-days/TwelveDaysTest.cs +++ b/exercises/twelve-days/TwelveDaysTest.cs @@ -1,138 +1,118 @@ -using NUnit.Framework; +using Xunit; -[TestFixture] public class TwelveDaysTest { - private TwelveDaysSong twelveDaysSong; + private readonly TwelveDaysSong twelveDaysSong = new TwelveDaysSong(); - [SetUp] - public void Setup() - { - twelveDaysSong = new TwelveDaysSong(); - } - - [Test] + [Fact] public void Return_verse_1() { var expected = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(1), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(1)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_2() { var expected = "On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(2), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(2)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_3() { var expected = "On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(3), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_4() { var expected = "On the fourth day of Christmas my true love gave to me, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(4), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(4)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_5() { var expected = "On the fifth day of Christmas my true love gave to me, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(5), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(5)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_6() { var expected = "On the sixth day of Christmas my true love gave to me, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(6), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(6)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_7() { var expected = "On the seventh day of Christmas my true love gave to me, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(7), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(7)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_8() { var expected = "On the eighth day of Christmas my true love gave to me, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(8), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(8)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_9() { var expected = "On the ninth day of Christmas my true love gave to me, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(9), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(9)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_10() { var expected = "On the tenth day of Christmas my true love gave to me, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(10), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(10)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_11() { var expected = "On the eleventh day of Christmas my true love gave to me, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(11), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(11)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_verse_12() { var expected = "On the twelfth day of Christmas my true love gave to me, twelve Drummers Drumming, eleven Pipers Piping, ten Lords-a-Leaping, nine Ladies Dancing, eight Maids-a-Milking, seven Swans-a-Swimming, six Geese-a-Laying, five Gold Rings, four Calling Birds, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n"; - Assert.That(twelveDaysSong.Verse(12), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verse(12)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_multiple_verses() { var expected = "On the first day of Christmas my true love gave to me, a Partridge in a Pear Tree.\n\n" + "On the second day of Christmas my true love gave to me, two Turtle Doves, and a Partridge in a Pear Tree.\n\n" + "On the third day of Christmas my true love gave to me, three French Hens, two Turtle Doves, and a Partridge in a Pear Tree.\n\n"; - Assert.That(twelveDaysSong.Verses(1, 3), Is.EqualTo(expected)); + Assert.Equal(expected, twelveDaysSong.Verses(1, 3)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Return_entire_song() { - Assert.That(twelveDaysSong.Verses(1, 12), Is.EqualTo(twelveDaysSong.Sing())); + Assert.Equal(twelveDaysSong.Sing(), twelveDaysSong.Verses(1, 12)); } } \ No newline at end of file diff --git a/exercises/two-bucket/TwoBucketTest.cs b/exercises/two-bucket/TwoBucketTest.cs index dfe989e71c..438e4decd6 100644 --- a/exercises/two-bucket/TwoBucketTest.cs +++ b/exercises/two-bucket/TwoBucketTest.cs @@ -1,8 +1,8 @@ -using NUnit.Framework; +using Xunit; public class TwoBucketTest { - [Test] + [Fact] public void First_example() { var bucketOneSize = 3; @@ -13,13 +13,12 @@ public void First_example() var actual = twoBuckets.Solve(goal); - Assert.That(actual.Moves, Is.EqualTo(4)); - Assert.That(actual.GoalBucket, Is.EqualTo(Bucket.One)); - Assert.That(actual.OtherBucketContents, Is.EqualTo(5)); + Assert.Equal(4, actual.Moves); + Assert.Equal(Bucket.One, actual.GoalBucket); + Assert.Equal(5, actual.OtherBucketContents); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Second_example() { var bucketOneSize = 3; @@ -30,13 +29,12 @@ public void Second_example() var actual = twoBuckets.Solve(goal); - Assert.That(actual.Moves, Is.EqualTo(8)); - Assert.That(actual.GoalBucket, Is.EqualTo(Bucket.Two)); - Assert.That(actual.OtherBucketContents, Is.EqualTo(3)); + Assert.Equal(8, actual.Moves); + Assert.Equal(Bucket.Two, actual.GoalBucket); + Assert.Equal(3, actual.OtherBucketContents); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Third_example() { var bucketOneSize = 7; @@ -47,13 +45,12 @@ public void Third_example() var actual = twoBuckets.Solve(goal); - Assert.That(actual.Moves, Is.EqualTo(14)); - Assert.That(actual.GoalBucket, Is.EqualTo(Bucket.One)); - Assert.That(actual.OtherBucketContents, Is.EqualTo(11)); + Assert.Equal(14, actual.Moves); + Assert.Equal(Bucket.One, actual.GoalBucket); + Assert.Equal(11, actual.OtherBucketContents); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Fourth_example() { var bucketOneSize = 7; @@ -64,8 +61,8 @@ public void Fourth_example() var actual = twoBuckets.Solve(goal); - Assert.That(actual.Moves, Is.EqualTo(18)); - Assert.That(actual.GoalBucket, Is.EqualTo(Bucket.Two)); - Assert.That(actual.OtherBucketContents, Is.EqualTo(7)); + Assert.Equal(18, actual.Moves); + Assert.Equal(Bucket.Two, actual.GoalBucket); + Assert.Equal(7, actual.OtherBucketContents); } } \ No newline at end of file diff --git a/exercises/variable-length-quantity/VariableLengthQuantityTest.cs b/exercises/variable-length-quantity/VariableLengthQuantityTest.cs index e3e94d3e2a..61ccdf92bc 100644 --- a/exercises/variable-length-quantity/VariableLengthQuantityTest.cs +++ b/exercises/variable-length-quantity/VariableLengthQuantityTest.cs @@ -1,99 +1,88 @@ -using NUnit.Framework; +using System; +using Xunit; public class VariableLengthQuantityTest { - [Test] + [Fact] public void To_single_byte() { - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x00u }), Is.EqualTo(new[] { 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x40u }), Is.EqualTo(new[] { 0x40u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x7fu }), Is.EqualTo(new[] { 0x7fu })); + Assert.Equal(new[] { 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x00u })); + Assert.Equal(new[] { 0x40u }, VariableLengthQuantity.ToBytes(new[] { 0x40u })); + Assert.Equal(new[] { 0x7fu }, VariableLengthQuantity.ToBytes(new[] { 0x7fu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void To_double_byte() { - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x80u }), Is.EqualTo(new[] { 0x81u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x2000u }), Is.EqualTo(new[] { 0xc0u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x3fffu }), Is.EqualTo(new[] { 0xffu, 0x7fu })); + Assert.Equal(new[] { 0x81u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x80u })); + Assert.Equal(new[] { 0xc0u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x2000u })); + Assert.Equal(new[] { 0xffu, 0x7fu }, VariableLengthQuantity.ToBytes(new[] { 0x3fffu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void To_triple_byte() { - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x4000u }), Is.EqualTo(new[] { 0x81u, 0x80u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x100000u }), Is.EqualTo(new[] { 0xc0u, 0x80u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x1fffffu }), Is.EqualTo(new[] { 0xffu, 0xffu, 0x7fu })); + Assert.Equal(new[] { 0x81u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x4000u })); + Assert.Equal(new[] { 0xc0u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x100000u })); + Assert.Equal(new[] { 0xffu, 0xffu, 0x7fu }, VariableLengthQuantity.ToBytes(new[] { 0x1fffffu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void To_quadruple_byte() { - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x200000u }), Is.EqualTo(new[] { 0x81u, 0x80u, 0x80u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x08000000u }), Is.EqualTo(new[] { 0xc0u, 0x80u, 0x80u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x0fffffffu }), Is.EqualTo(new[] { 0xffu, 0xffu, 0xffu, 0x7fu })); + Assert.Equal(new[] { 0x81u, 0x80u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x200000u })); + Assert.Equal(new[] { 0xc0u, 0x80u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x08000000u })); + Assert.Equal(new[] { 0xffu, 0xffu, 0xffu, 0x7fu }, VariableLengthQuantity.ToBytes(new[] { 0x0fffffffu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void To_quintuple_byte() { - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x10000000u }), Is.EqualTo(new[] { 0x81u, 0x80u, 0x80u, 0x80u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0xff000000u }), Is.EqualTo(new[] { 0x8fu, 0xf8u, 0x80u, 0x80u, 0x00u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0xffffffffu }), Is.EqualTo(new[] { 0x8fu, 0xffu, 0xffu, 0xffu, 0x7fu })); + Assert.Equal(new[] { 0x81u, 0x80u, 0x80u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x10000000u })); + Assert.Equal(new[] { 0x8fu, 0xf8u, 0x80u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0xff000000u })); + Assert.Equal(new[] { 0x8fu, 0xffu, 0xffu, 0xffu, 0x7fu }, VariableLengthQuantity.ToBytes(new[] { 0xffffffffu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void From_bytes() { - Assert.That(VariableLengthQuantity.FromBytes(new[] { 0x7fu }), Is.EqualTo(new[] { 0x7fu })); - Assert.That(VariableLengthQuantity.FromBytes(new[] { 0xc0u, 0x00u }), Is.EqualTo(new[] { 0x2000u })); - Assert.That(VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0x7fu }), Is.EqualTo(new[] { 0x1fffffu })); - Assert.That(VariableLengthQuantity.FromBytes(new[] { 0x81u, 0x80u, 0x80u, 0x00u }), Is.EqualTo(new[] { 0x200000u })); - Assert.That(VariableLengthQuantity.FromBytes(new[] { 0x8fu, 0xffu, 0xffu, 0xffu, 0x7fu }), Is.EqualTo(new[] { 0xffffffffu })); + Assert.Equal(new[] { 0x7fu }, VariableLengthQuantity.FromBytes(new[] { 0x7fu })); + Assert.Equal(new[] { 0x2000u }, VariableLengthQuantity.FromBytes(new[] { 0xc0u, 0x00u })); + Assert.Equal(new[] { 0x1fffffu }, VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0x7fu })); + Assert.Equal(new[] { 0x200000u }, VariableLengthQuantity.FromBytes(new[] { 0x81u, 0x80u, 0x80u, 0x00u })); + Assert.Equal(new[] { 0xffffffffu }, VariableLengthQuantity.FromBytes(new[] { 0x8fu, 0xffu, 0xffu, 0xffu, 0x7fu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void To_bytes_multiple_values() { - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x40u, 0x7fu }), Is.EqualTo(new[] { 0x40u, 0x7fu })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x4000u, 0x123456u }), Is.EqualTo(new[] { 0x81u, 0x80u, 0x00u, 0xc8u, 0xe8u, 0x56u })); - Assert.That(VariableLengthQuantity.ToBytes(new[] { 0x2000u, 0x123456u, 0x0fffffffu, 0x00u, 0x3fffu, 0x4000u }), - Is.EqualTo(new[] { 0xc0u, 0x00u, 0xc8u, 0xe8u, 0x56u, 0xffu, 0xffu, 0xffu, 0x7fu, 0x00u, 0xffu, 0x7fu, 0x81u, 0x80u, 0x00u })); + Assert.Equal(new[] { 0x40u, 0x7fu }, VariableLengthQuantity.ToBytes(new[] { 0x40u, 0x7fu })); + Assert.Equal(new[] { 0x81u, 0x80u, 0x00u, 0xc8u, 0xe8u, 0x56u }, VariableLengthQuantity.ToBytes(new[] { 0x4000u, 0x123456u })); + Assert.Equal(new[] { 0xc0u, 0x00u, 0xc8u, 0xe8u, 0x56u, 0xffu, 0xffu, 0xffu, 0x7fu, 0x00u, 0xffu, 0x7fu, 0x81u, 0x80u, 0x00u }, VariableLengthQuantity.ToBytes(new[] { 0x2000u, 0x123456u, 0x0fffffffu, 0x00u, 0x3fffu, 0x4000u })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void From_bytes_multiple_values() { - Assert.That(VariableLengthQuantity.FromBytes(new[] { 0xc0u, 0x00u, 0xc8u, 0xe8u, 0x56u, 0xffu, 0xffu, 0xffu, 0x7fu, 0x00u, 0xffu, 0x7fu, 0x81u, 0x80u, 0x00u }), - Is.EqualTo(new[] { 0x2000u, 0x123456u, 0x0fffffffu, 0x00u, 0x3fffu, 0x4000u })); + Assert.Equal(new[] { 0x2000u, 0x123456u, 0x0fffffffu, 0x00u, 0x3fffu, 0x4000u }, VariableLengthQuantity.FromBytes(new[] { 0xc0u, 0x00u, 0xc8u, 0xe8u, 0x56u, 0xffu, 0xffu, 0xffu, 0x7fu, 0x00u, 0xffu, 0x7fu, 0x81u, 0x80u, 0x00u })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Incomplete_byte_sequence() { - Assert.That(() => VariableLengthQuantity.FromBytes(new[] { 0xffu }), Throws.Exception); + Assert.Throws(() => VariableLengthQuantity.FromBytes(new[] { 0xffu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Overflow() { - Assert.That(() => VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0xffu, 0xffu, 0x7fu }), Throws.Exception); + Assert.Throws(() => VariableLengthQuantity.FromBytes(new[] { 0xffu, 0xffu, 0xffu, 0xffu, 0x7fu })); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Chained_execution_is_identity() { var test = new[] { 0xf2u, 0xf6u, 0x96u, 0x9cu, 0x3bu, 0x39u, 0x2eu, 0x30u, 0xb3u, 0x24u }; - Assert.That(VariableLengthQuantity.FromBytes(VariableLengthQuantity.ToBytes(test)), Is.EquivalentTo(test)); + Assert.Equal(test, VariableLengthQuantity.FromBytes(VariableLengthQuantity.ToBytes(test))); } } \ No newline at end of file diff --git a/exercises/word-count/WordCountTest.cs b/exercises/word-count/WordCountTest.cs index 06cb02490c..5295ccd724 100644 --- a/exercises/word-count/WordCountTest.cs +++ b/exercises/word-count/WordCountTest.cs @@ -1,21 +1,19 @@ using System.Collections.Generic; -using NUnit.Framework; +using Xunit; -[TestFixture] public class WordCountTest { - [Test] + [Fact] public void Count_one_word() { var counts = new Dictionary { { "word", 1 } }; - Assert.That(Phrase.WordCount("word"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("word")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Count_one_of_each() { var counts = new Dictionary { @@ -24,11 +22,10 @@ public void Count_one_of_each() { "each", 1 } }; - Assert.That(Phrase.WordCount("one of each"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("one of each")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Count_multiple_occurrences() { var counts = new Dictionary { @@ -39,11 +36,10 @@ public void Count_multiple_occurrences() { "blue", 1 }, }; - Assert.That(Phrase.WordCount("one fish two fish red fish blue fish"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("one fish two fish red fish blue fish")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Count_everything_just_once() { var counts = new Dictionary { @@ -55,11 +51,10 @@ public void Count_everything_just_once() { "men", 1 }, }; - Assert.That(Phrase.WordCount("all the kings horses and all the kings men"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("all the kings horses and all the kings men")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Ignore_punctuation() { var counts = new Dictionary { @@ -70,11 +65,10 @@ public void Ignore_punctuation() { "javascript", 1 }, }; - Assert.That(Phrase.WordCount("car : carpet as java : javascript!!&@$%^&"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("car : carpet as java : javascript!!&@$%^&")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Handles_cramped_list() { var counts = new Dictionary { @@ -83,11 +77,10 @@ public void Handles_cramped_list() { "three", 1 }, }; - Assert.That(Phrase.WordCount("one,two,three"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("one,two,three")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Include_numbers() { var counts = new Dictionary { @@ -96,22 +89,20 @@ public void Include_numbers() { "2", 1 }, }; - Assert.That(Phrase.WordCount("testing, 1, 2 testing"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("testing, 1, 2 testing")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Normalize_case() { var counts = new Dictionary { { "go", 3 }, }; - Assert.That(Phrase.WordCount("go Go GO"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("go Go GO")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void With_apostrophes() { var counts = new Dictionary { @@ -122,22 +113,20 @@ public void With_apostrophes() { "cry", 1 }, }; - Assert.That(Phrase.WordCount("First: don't laugh. Then: don't cry."), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("First: don't laugh. Then: don't cry.")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void With_free_standing_apostrophes() { var counts = new Dictionary { { "go", 3 }, }; - Assert.That(Phrase.WordCount("go ' Go '' GO"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("go ' Go '' GO")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void With_apostrophes_as_quotes() { var counts = new Dictionary { @@ -150,7 +139,7 @@ public void With_apostrophes_as_quotes() { "o'clock", 1 }, }; - Assert.That(Phrase.WordCount("She said, 'let's meet at twelve o'clock'"), Is.EqualTo(counts)); + Assert.Equal(counts, Phrase.WordCount("She said, 'let's meet at twelve o'clock'")); } } \ No newline at end of file diff --git a/exercises/word-search/WordSearchTest.cs b/exercises/word-search/WordSearchTest.cs index 6a82c8bc16..87ad1206c2 100644 --- a/exercises/word-search/WordSearchTest.cs +++ b/exercises/word-search/WordSearchTest.cs @@ -1,6 +1,6 @@ using System; using System.Drawing; -using NUnit.Framework; +using Xunit; public class WordSearchTest { @@ -16,88 +16,87 @@ public class WordSearchTest "jalaycalmp\n" + "clojurermt"; - [Test] + [Fact] public void Should_find_horizontal_words_written_left_to_right() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("clojure"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(1, 10), new Point(7, 10)))); + Assert.Equal(new Point(1, 10), actual.Item1); + Assert.Equal(new Point(7, 10), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_horizontal_words_written_right_to_left() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("elixir"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(6, 5), new Point(1, 5)))); + Assert.Equal(new Point(6, 5), actual.Item1); + Assert.Equal(new Point(1, 5), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_vertical_words_written_top_to_bottom() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("ecmascript"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(10, 1), new Point(10, 10)))); + Assert.Equal(new Point(10, 1), actual.Item1); + Assert.Equal(new Point(10, 10), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_vertical_words_written_bottom_to_top() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("rust"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(9, 5), new Point(9, 2)))); + Assert.Equal(new Point(9, 5), actual.Item1); + Assert.Equal(new Point(9, 2), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_diagonal_words_written_top_left_to_bottom_right() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("java"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(1, 1), new Point(4, 4)))); + Assert.Equal(new Point(1, 1), actual.Item1); + Assert.Equal(new Point(4, 4), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_diagonal_upper_written_bottom_right_to_top_left() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("lua"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(8, 9), new Point(6, 7)))); + Assert.Equal(new Point(8, 9), actual.Item1); + Assert.Equal(new Point(6, 7), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_diagonal_upper_written_bottom_left_to_top_right() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("lisp"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(3, 6), new Point(6, 3)))); + Assert.Equal(new Point(3, 6), actual.Item1); + Assert.Equal(new Point(6, 3), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_find_diagonal_upper_written_top_right_to_bottom_left() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("ruby"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(8, 6), new Point(5, 9)))); + Assert.Equal(new Point(8, 6), actual.Item1); + Assert.Equal(new Point(5, 9), actual.Item2); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_not_find_words_that_are_not_in_the_puzzle() { var wordSearch = new WordSearch(Puzzle); var actual = wordSearch.Find("haskell"); - Assert.That(actual, Is.Null); + Assert.Null(actual); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Should_be_able_to_search_differently_sized_puzzles() { const string differentSizePuzzle = @@ -107,6 +106,7 @@ public void Should_be_able_to_search_differently_sized_puzzles() var wordSearch = new WordSearch(differentSizePuzzle); var actual = wordSearch.Find("exercism"); - Assert.That(actual, Is.EqualTo(Tuple.Create(new Point(11, 2), new Point(4, 2)))); + Assert.Equal(new Point(11, 2), actual.Item1); + Assert.Equal(new Point(4, 2), actual.Item2); } } \ No newline at end of file diff --git a/exercises/wordy/WordyTest.cs b/exercises/wordy/WordyTest.cs index 559cfc7258..7ea2281cac 100644 --- a/exercises/wordy/WordyTest.cs +++ b/exercises/wordy/WordyTest.cs @@ -1,116 +1,101 @@ -using NUnit.Framework; +using System; +using Xunit; -[TestFixture] public class WordProblemTest { - [Test] + [Fact] public void Can_parse_and_solve_addition_problems() { - Assert.That(WordProblem.Solve("What is 1 plus 1?"), Is.EqualTo(2)); + Assert.Equal(2, WordProblem.Solve("What is 1 plus 1?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_double_digit_numbers() { - Assert.That(WordProblem.Solve("What is 53 plus 2?"), Is.EqualTo(55)); + Assert.Equal(55, WordProblem.Solve("What is 53 plus 2?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_negative_numbers() { - Assert.That(WordProblem.Solve("What is -1 plus -10?"), Is.EqualTo(-11)); + Assert.Equal(-11, WordProblem.Solve("What is -1 plus -10?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_large_numbers() { - Assert.That(WordProblem.Solve("What is 123 plus 45678?"), Is.EqualTo(45801)); + Assert.Equal(45801, WordProblem.Solve("What is 123 plus 45678?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_parse_and_solve_subtraction_problems() { - Assert.That(WordProblem.Solve("What is 4 minus -12"), Is.EqualTo(16)); + Assert.Equal(16, WordProblem.Solve("What is 4 minus -12")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_parse_and_solve_multiplication_problems() { - Assert.That(WordProblem.Solve("What is -3 multiplied by 25?"), Is.EqualTo(-75)); + Assert.Equal(-75, WordProblem.Solve("What is -3 multiplied by 25?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_parse_and_solve_division_problems() { - Assert.That(WordProblem.Solve("What is 33 divided by -3?"), Is.EqualTo(-11)); + Assert.Equal(-11, WordProblem.Solve("What is 33 divided by -3?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_twice() { - Assert.That(WordProblem.Solve("What is 1 plus 1 plus 1?"), Is.EqualTo(3)); + Assert.Equal(3, WordProblem.Solve("What is 1 plus 1 plus 1?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_then_subtract() { - Assert.That(WordProblem.Solve("What is 1 plus 5 minus -2?"), Is.EqualTo(8)); + Assert.Equal(8, WordProblem.Solve("What is 1 plus 5 minus -2?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_subtract_twice() { - Assert.That(WordProblem.Solve("What is 20 minus 4 minus 13?"), Is.EqualTo(3)); + Assert.Equal(3, WordProblem.Solve("What is 20 minus 4 minus 13?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_subtract_then_add() { - Assert.That(WordProblem.Solve("What is 17 minus 6 plus 3?"), Is.EqualTo(14)); + Assert.Equal(14, WordProblem.Solve("What is 17 minus 6 plus 3?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_multiply_twice() { - Assert.That(WordProblem.Solve("What is 2 multiplied by -2 multiplied by 3?"), Is.EqualTo(-12)); + Assert.Equal(-12, WordProblem.Solve("What is 2 multiplied by -2 multiplied by 3?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_add_then_multiply() { - Assert.That(WordProblem.Solve("What is -3 plus 7 multiplied by -2?"), Is.EqualTo(-8)); + Assert.Equal(-8, WordProblem.Solve("What is -3 plus 7 multiplied by -2?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Can_divide_twice() { - Assert.That(WordProblem.Solve("What is -12 divided by 2 divided by -3?"), Is.EqualTo(2)); + Assert.Equal(2, WordProblem.Solve("What is -12 divided by 2 divided by -3?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Cubed_is_too_advanced() { - Assert.That(() => WordProblem.Solve("What is 53 cubed?"), Throws.ArgumentException); + Assert.Throws(() => WordProblem.Solve("What is 53 cubed?")); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Irrelevant_problems_are_not_valid() { - Assert.That(() => WordProblem.Solve("Who is the president of the United States?"), Throws.ArgumentException); + Assert.Throws(() => WordProblem.Solve("Who is the president of the United States?")); } } diff --git a/exercises/zebra-puzzle/ZebraPuzzleTest.cs b/exercises/zebra-puzzle/ZebraPuzzleTest.cs index 10f45d9a86..6cde1b2c2f 100644 --- a/exercises/zebra-puzzle/ZebraPuzzleTest.cs +++ b/exercises/zebra-puzzle/ZebraPuzzleTest.cs @@ -1,17 +1,16 @@ -using NUnit.Framework; +using Xunit; public class ZebraPuzzleTest { - [Test] + [Fact] public void Who_drinks_water() { - Assert.That(ZebraPuzzle.WhoDrinks(Drink.Water), Is.EqualTo(Nationality.Norwegian)); + Assert.Equal(Nationality.Norwegian, ZebraPuzzle.WhoDrinks(Drink.Water)); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Who_owns_the_zebra() { - Assert.That(ZebraPuzzle.WhoOwns(Pet.Zebra), Is.EqualTo(Nationality.Japanese)); + Assert.Equal(Nationality.Japanese, ZebraPuzzle.WhoOwns(Pet.Zebra)); } } \ No newline at end of file diff --git a/exercises/zipper/ZipperTest.cs b/exercises/zipper/ZipperTest.cs index feeed02c84..f1605ae407 100644 --- a/exercises/zipper/ZipperTest.cs +++ b/exercises/zipper/ZipperTest.cs @@ -1,4 +1,4 @@ -using NUnit.Framework; +using Xunit; public class ZipperTest { @@ -11,73 +11,66 @@ public class ZipperTest private static readonly BinTree t3 = new BinTree(1, bt(2, leaf(5), leaf(3)), leaf(4)); private static readonly BinTree t4 = new BinTree(1, leaf(2), leaf(4)); - [Test] + [Fact] public void Data_is_retained() { var zipper = Zipper.FromTree(t1); var tree = zipper.ToTree(); - Assert.That(tree, Is.EqualTo(t1)); + Assert.Equal(t1, tree); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Left_right_and_value() { var zipper = Zipper.FromTree(t1); - Assert.That(zipper.Left().Right().Value, Is.EqualTo(3)); + Assert.Equal(3, zipper.Left().Right().Value); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Dead_end() { var zipper = Zipper.FromTree(t1); - Assert.That(zipper.Left().Left(), Is.Null); + Assert.Null(zipper.Left().Left()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Tree_from_deep_focus() { var zipper = Zipper.FromTree(t1); - Assert.That(zipper.Left().Right().ToTree(), Is.EqualTo(t1)); + Assert.Equal(t1, zipper.Left().Right().ToTree()); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Set_value() { var zipper = Zipper.FromTree(t1); var updatedZipper = zipper.Left().SetValue(5); var tree = updatedZipper.ToTree(); - Assert.That(tree, Is.EqualTo(t2)); + Assert.Equal(t2, tree); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Set_left_with_value() { var zipper = Zipper.FromTree(t1); var updatedZipper = zipper.Left().SetLeft(new BinTree(5, null, null)); var tree = updatedZipper.ToTree(); - Assert.That(tree, Is.EqualTo(t3)); + Assert.Equal(t3, tree); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Set_right_to_null() { var zipper = Zipper.FromTree(t1); var updatedZipper = zipper.Left().SetRight(null); var tree = updatedZipper.ToTree(); - Assert.That(tree, Is.EqualTo(t4)); + Assert.Equal(t4, tree); } - [Ignore("Remove to run test")] - [Test] + [Fact(Skip = "Remove to run test")] public void Different_paths_to_same_zipper() { var zipper = Zipper.FromTree(t1); - Assert.That(zipper.Left().Up().Right().ToTree(), Is.EqualTo(zipper.Right().ToTree())); + Assert.Equal(zipper.Right().ToTree(), zipper.Left().Up().Right().ToTree()); } } diff --git a/paket.dependencies b/paket.dependencies index f0d9b2cfbd..65f7891752 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -1,6 +1,5 @@ source https://www.nuget.org/api/v2/ nuget FAKE -nuget NUnit -nuget NUnit.ConsoleRunner nuget Sprache -github nunit/nunit-transforms nunit3-junit/nunit3-junit.xslt \ No newline at end of file +nuget xunit +nuget xunit.runner.console \ No newline at end of file diff --git a/paket.lock b/paket.lock index a5c07c45eb..cf5c9d5d24 100644 --- a/paket.lock +++ b/paket.lock @@ -1,80 +1,163 @@ NUGET remote: https://www.nuget.org/api/v2 - FAKE (4.37.2) - Microsoft.NETCore.Platforms (1.0.1) - framework: netstandard10, >= netstandard12 - Microsoft.NETCore.Targets (1.0.1) - framework: netstandard10, >= netstandard12 - NUnit (3.4.1) - NUnit.ConsoleRunner (3.4.1) + FAKE (4.50) + Microsoft.NETCore.Platforms (1.1) - framework: dnxcore50, netstandard10, >= netstandard12 + Microsoft.NETCore.Targets (1.1) - framework: dnxcore50, netstandard10, >= netstandard12 Sprache (2.1) System.Globalization (>= 4.0.11) - framework: >= netstandard10 System.Linq (>= 4.1) - framework: >= netstandard10 System.Runtime (>= 4.1) - framework: >= netstandard10 System.Text.RegularExpressions (>= 4.1) - framework: >= netstandard10 - System.Collections (4.0.11) - framework: netstandard10, >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Diagnostics.Debug (4.0.11) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Globalization (4.0.11) - framework: >= netstandard10 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.IO (4.1) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Text.Encoding (>= 4.0.11) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Threading.Tasks (>= 4.0.11) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Linq (4.1) - framework: >= netstandard10 - System.Collections (>= 4.0.11) - framework: dnxcore50, netstandard10, >= netstandard16 - System.Diagnostics.Debug (>= 4.0.11) - framework: dnxcore50, >= netstandard16 - System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard16 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard16 - System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard16 - System.Reflection (4.1) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.IO (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Reflection.Primitives (>= 4.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Reflection.Primitives (4.0.1) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, >= netstandard10 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, >= netstandard10 - System.Runtime (>= 4.1) - framework: dnxcore50, >= netstandard10 - System.Resources.ResourceManager (4.0.1) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, >= netstandard10 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, >= netstandard10 - System.Globalization (>= 4.0.11) - framework: dnxcore50, >= netstandard10 - System.Reflection (>= 4.1) - framework: dnxcore50, >= netstandard10 - System.Runtime (>= 4.1) - framework: dnxcore50, >= netstandard10 - System.Runtime (4.1) - framework: >= netstandard10 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15 - System.Runtime.Extensions (4.1) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 - System.Text.Encoding (4.0.11) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Text.RegularExpressions (4.1) - framework: >= netstandard10 - System.Collections (>= 4.0.11) - framework: dnxcore50, >= netstandard16 - System.Globalization (>= 4.0.11) - framework: dnxcore50, >= netstandard16 - System.Resources.ResourceManager (>= 4.0.1) - framework: dnxcore50, >= netstandard16 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16 - System.Runtime.Extensions (>= 4.1) - framework: dnxcore50, >= netstandard16 - System.Threading (>= 4.0.11) - framework: dnxcore50, >= netstandard16 - System.Threading (4.0.11) - framework: >= netstandard16 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Threading.Tasks (>= 4.0.11) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Threading.Tasks (4.0.11) - framework: >= netstandard16 - Microsoft.NETCore.Platforms (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - Microsoft.NETCore.Targets (>= 1.0.1) - framework: dnxcore50, netstandard10, >= netstandard13 - System.Runtime (>= 4.1) - framework: dnxcore50, netstandard10, >= netstandard13 -GITHUB - remote: nunit/nunit-transforms - nunit3-junit/nunit3-junit.xslt (2a7c74198375b4b280ff3e79033c3d44e3083850) \ No newline at end of file + System.Collections (4.3) - framework: dnxcore50, netstandard10, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Diagnostics.Contracts (4.3) - framework: dnxcore50 + System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Diagnostics.Debug (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Globalization (4.3) - framework: dnxcore50, >= netstandard10 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.IO (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Text.Encoding (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Threading.Tasks (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Linq (4.3) - framework: dnxcore50, >= netstandard10 + System.Collections (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard16 + System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard16 + System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Linq.Expressions (4.3) - framework: dnxcore50 + System.Collections (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Globalization (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.IO (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Linq (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Reflection (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16 + System.Reflection.Emit.ILGeneration (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Reflection.Emit.Lightweight (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Reflection.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Reflection.Primitives (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Reflection.TypeExtensions (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16 + System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.ObjectModel (4.3) - framework: dnxcore50 + System.Collections (>= 4.3) - framework: dnxcore50, >= netstandard13 + System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50, >= netstandard13 + System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50, >= netstandard13 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard13 + System.Reflection (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.IO (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Reflection.Primitives (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Reflection.Emit.ILGeneration (4.3) - framework: dnxcore50 + System.Reflection.Emit.Lightweight (4.3) - framework: dnxcore50 + System.Reflection.Extensions (4.3) - framework: dnxcore50 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, >= netstandard10 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, >= netstandard10 + System.Reflection (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Reflection.Primitives (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, >= netstandard10 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, >= netstandard10 + System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Reflection.TypeExtensions (4.3) - framework: dnxcore50 + System.Diagnostics.Contracts (>= 4.3) - framework: dnxcore50 + System.Diagnostics.Debug (>= 4.3) - framework: dnxcore50 + System.Linq (>= 4.3) - framework: dnxcore50 + System.Reflection (>= 4.3) - framework: >= net462, dnxcore50, netstandard13, >= netstandard15 + System.Reflection.Primitives (>= 4.3) - framework: dnxcore50 + System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard13, >= netstandard15 + System.Runtime.Extensions (>= 4.3) - framework: dnxcore50 + System.Resources.ResourceManager (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, >= netstandard10 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, >= netstandard10 + System.Globalization (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Reflection (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Runtime (>= 4.3) - framework: dnxcore50, >= netstandard10 + System.Runtime (4.3) - framework: dnxcore50, >= netstandard10 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, netstandard12, netstandard13, >= netstandard15 + System.Runtime.Extensions (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard15 + System.Text.Encoding (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Text.RegularExpressions (4.3) - framework: dnxcore50, >= netstandard10 + System.Collections (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Globalization (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Resources.ResourceManager (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, netstandard13, >= netstandard16, netcore11 + System.Runtime.Extensions (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Threading (>= 4.3) - framework: dnxcore50, >= netstandard16 + System.Threading (4.3) - framework: dnxcore50, >= netstandard16 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Threading.Tasks (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Threading.Tasks (4.3) - framework: dnxcore50, >= netstandard16 + Microsoft.NETCore.Platforms (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + Microsoft.NETCore.Targets (>= 1.1) - framework: dnxcore50, netstandard10, >= netstandard13 + System.Runtime (>= 4.3) - framework: dnxcore50, netstandard10, >= netstandard13 + xunit (2.1) + xunit.assert (2.1) + xunit.core (2.1) + xunit.abstractions (2.0) - framework: >= net45, dnx451, dnxcore50, monoandroid, monotouch, portable-net45+win80+wp80+wpa81, xamarinios, winv4.5, wpv8.0, wpav8.1 + xunit.assert (2.1) + System.Collections (>= 4.0) - framework: dnxcore50 + System.Diagnostics.Debug (>= 4.0) - framework: dnxcore50 + System.Globalization (>= 4.0) - framework: dnxcore50 + System.Linq (>= 4.0) - framework: dnxcore50 + System.ObjectModel (>= 4.0) - framework: dnxcore50 + System.Reflection (>= 4.0) - framework: dnxcore50 + System.Reflection.Extensions (>= 4.0) - framework: dnxcore50 + System.Runtime (>= 4.0) - framework: dnxcore50 + System.Runtime.Extensions (>= 4.0) - framework: dnxcore50 + System.Text.RegularExpressions (>= 4.0) - framework: dnxcore50 + System.Threading.Tasks (>= 4.0) - framework: dnxcore50 + xunit.core (2.1) + System.Collections (>= 4.0) - framework: dnxcore50 + System.Diagnostics.Debug (>= 4.0) - framework: dnxcore50 + System.Globalization (>= 4.0) - framework: dnxcore50 + System.Linq (>= 4.0) - framework: dnxcore50 + System.Reflection (>= 4.0) - framework: dnxcore50 + System.Reflection.Extensions (>= 4.0) - framework: dnxcore50 + System.Runtime (>= 4.0) - framework: dnxcore50 + System.Runtime.Extensions (>= 4.0) - framework: dnxcore50 + System.Threading.Tasks (>= 4.0) - framework: dnxcore50 + xunit.abstractions (>= 2.0) - framework: dnxcore50 + xunit.extensibility.core (2.1) - framework: >= net45, dnx451, dnxcore50, monoandroid, monotouch, portable-net45+win80+wp80+wpa81, xamarinios, winv4.5, wpv8.0, wpav8.1 + xunit.extensibility.execution (2.1) - framework: >= net45, dnx451, dnxcore50, monoandroid, monotouch, portable-net45+win80+wp80+wpa81, xamarinios, winv4.5, wpv8.0, wpav8.1 + xunit.extensibility.core (2.1) - framework: >= net45, dnx451, dnxcore50, monoandroid, monotouch, portable-net45+win80+wp80+wpa81, xamarinios, winv4.5, wpv8.0, wpav8.1 + xunit.abstractions (2.0) + xunit.extensibility.execution (2.1) - framework: >= net45, dnx451, dnxcore50, monoandroid, monotouch, portable-net45+win80+wp80+wpa81, xamarinios, winv4.5, wpv8.0, wpav8.1 + System.Collections (>= 4.0) - framework: dnxcore50 + System.Diagnostics.Debug (>= 4.0) - framework: dnxcore50 + System.Globalization (>= 4.0) - framework: dnxcore50 + System.IO (>= 4.0) - framework: dnxcore50 + System.Linq (>= 4.0) - framework: dnxcore50 + System.Linq.Expressions (>= 4.0) - framework: dnxcore50 + System.Reflection (>= 4.0) - framework: dnxcore50 + System.Reflection.Extensions (>= 4.0) - framework: dnxcore50 + System.Runtime (>= 4.0) - framework: dnxcore50 + System.Runtime.Extensions (>= 4.0) - framework: dnxcore50 + System.Text.Encoding (>= 4.0) - framework: dnxcore50 + System.Threading (>= 4.0) - framework: dnxcore50 + System.Threading.Tasks (>= 4.0) - framework: dnxcore50 + xunit.abstractions (>= 2.0) - framework: dnxcore50 + xunit.extensibility.core (2.1) - framework: >= net45, dnx451, dnxcore50, monoandroid, monotouch, xamarinios, winv4.5, wpv8.0, wpav8.1 + xunit.runner.console (2.1)