From 2fe69fc0e90f25599d826f77b7c51f517d501687 Mon Sep 17 00:00:00 2001 From: Ian Nelson Date: Tue, 3 Mar 2026 21:40:39 +0000 Subject: [PATCH] Migrate test framework from NUnit to xUnit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace NUnit packages with xUnit (xunit 2.9.3, xunit.runner.visualstudio 3.1.5, xunit.analyzers 1.18.0) - Convert test attributes: [TestFixture] removed, [Test] → [Fact], [TestCase] → [InlineData] with [Theory] - Convert assertions: Assert.That() → FluentAssertions, Assert.Fail() → Should().BeEmpty() - Update global using statement from NUnit.Framework to Xunit - Update documentation to reflect xUnit usage All 434 tests passing (433 passed, 1 skipped). Co-Authored-By: Claude Sonnet 4.5 --- CLAUDE.md | 2 +- EulerLibTests/EulerLibTests.csproj | 9 +- .../Extensions/BigIntegerExtensionsFixture.cs | 6 +- .../Extensions/DivisorsExtensionFixture.cs | 38 +- .../Extensions/IntegerExtensionsFixture.cs | 16 +- .../Extensions/Md5ExtensionsFixture.cs | 9 +- .../PrimeFactorsExtensionFixture.cs | 9 +- .../RomanNumeralsExtensionsFixture.cs | 42 ++- .../SequenceMembershipExtensionsFixture.cs | 108 +++--- .../Extensions/StringExtensionsFixture.cs | 21 +- EulerLibTests/GlobalUsings.cs | 2 +- EulerLibTests/Monopoly/GameTests.cs | 4 +- EulerLibTests/Poker/CardFixture.cs | 57 +-- EulerLibTests/Poker/HandFixture.cs | 356 ++++++++++-------- .../Problems/0001_0100/Problem0001Fixture.cs | 3 +- .../Problems/0001_0100/Problem0002Fixture.cs | 3 +- .../Problems/0001_0100/Problem0003Fixture.cs | 3 +- .../Problems/0001_0100/Problem0004Fixture.cs | 10 +- .../Problems/0001_0100/Problem0005Fixture.cs | 3 +- .../Problems/0001_0100/Problem0006Fixture.cs | 7 +- .../Problems/0001_0100/Problem0007Fixture.cs | 3 +- .../Problems/0001_0100/Problem0008Fixture.cs | 19 +- .../Problems/0001_0100/Problem0010Fixture.cs | 3 +- .../Problems/0001_0100/Problem0011Fixture.cs | 13 +- .../Problems/0001_0100/Problem0012Fixture.cs | 3 +- .../Problems/0001_0100/Problem0014Fixture.cs | 11 +- .../Problems/0001_0100/Problem0015Fixture.cs | 6 +- .../Problems/0001_0100/Problem0016Fixture.cs | 8 +- .../Problems/0001_0100/Problem0018Fixture.cs | 3 +- .../Problems/0001_0100/Problem0025Fixture.cs | 4 +- .../Problems/0001_0100/Problem0026Fixture.cs | 25 +- .../Problems/0001_0100/Problem0028Fixture.cs | 8 +- .../Problems/0001_0100/Problem0029Fixture.cs | 3 +- .../Problems/0001_0100/Problem0030Fixture.cs | 4 +- .../Problems/0001_0100/Problem0031Fixture.cs | 14 +- .../Problems/0001_0100/Problem0037Fixture.cs | 7 +- .../Problems/0001_0100/Problem0043Fixture.cs | 19 +- .../Problems/0001_0100/Problem0047Fixture.cs | 19 +- .../Problems/0001_0100/Problem0054Fixture.cs | 3 +- .../Problems/0001_0100/Problem0055Fixture.cs | 12 +- .../Problems/0001_0100/Problem0092Fixture.cs | 27 +- .../Sequences/AbundantNumbersFixture.cs | 18 +- .../Sequences/DeficientNumbersFixture.cs | 24 +- .../Sequences/FibonacciNumbersFixture.cs | 5 +- .../Sequences/HexagonalNumbersFixture.cs | 5 +- .../Sequences/PentagonalNumbersFixture.cs | 5 +- .../Sequences/PerfectNumberFixture.cs | 8 +- .../Sequences/PrimeNumbersFixture.cs | 44 +-- .../Sequences/SquareNumbersFixture.cs | 5 +- .../Sequences/TriangularNumbersFixture.cs | 5 +- .../Sets/PandigitalNumbersFixture.cs | 9 +- EulerLibTests/SoakTestFixture.cs | 11 +- 52 files changed, 542 insertions(+), 519 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index acb04ea..1418856 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -9,7 +9,7 @@ dotnet test EulerLibTests/EulerLibTests.csproj ## Structure - **Euler/** - Console runner app (net8.0) - **EulerLib/** - Problem solutions library. Each problem implements `IProblem` (`Id`, `Title`, `Solve()`, `Md5OfSolution`) -- **EulerLibTests/** - Test project (NUnit + FluentAssertions + AutoFixture) +- **EulerLibTests/** - Test project (xUnit + FluentAssertions + AutoFixture) ## Conventions - Problems go in `EulerLib/Problems/0001_0100/Problem0001.cs` (namespace `EulerLib.Problems`) diff --git a/EulerLibTests/EulerLibTests.csproj b/EulerLibTests/EulerLibTests.csproj index 62f1611..113c467 100644 --- a/EulerLibTests/EulerLibTests.csproj +++ b/EulerLibTests/EulerLibTests.csproj @@ -10,9 +10,12 @@ - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/EulerLibTests/Extensions/BigIntegerExtensionsFixture.cs b/EulerLibTests/Extensions/BigIntegerExtensionsFixture.cs index 97a388e..fd19a06 100644 --- a/EulerLibTests/Extensions/BigIntegerExtensionsFixture.cs +++ b/EulerLibTests/Extensions/BigIntegerExtensionsFixture.cs @@ -3,11 +3,11 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class BigIntegerExtensionsFixture { - [TestCase("12345", 15)] - [TestCase("1234567890", 45)] + [Theory] + [InlineData("12345", 15)] + [InlineData("1234567890", 45)] public void SumOfDigits_Tests(string value, int expectedSumOfDigits) { var bigint = BigInteger.Parse(value); diff --git a/EulerLibTests/Extensions/DivisorsExtensionFixture.cs b/EulerLibTests/Extensions/DivisorsExtensionFixture.cs index 26de0f7..e9cb6ab 100644 --- a/EulerLibTests/Extensions/DivisorsExtensionFixture.cs +++ b/EulerLibTests/Extensions/DivisorsExtensionFixture.cs @@ -2,15 +2,15 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class DivisorsExtensionFixture { - [TestCase(1, 1, 1)] - [TestCase(2, 3, 2)] - [TestCase(4, 7, 3)] - [TestCase(16, 31, 5)] - [TestCase(220, 504, 12)] - [TestCase(284, 504, 6)] + [Theory] + [InlineData(1, 1, 1)] + [InlineData(2, 3, 2)] + [InlineData(4, 7, 3)] + [InlineData(16, 31, 5)] + [InlineData(220, 504, 12)] + [InlineData(284, 504, 6)] public void DivisorsTests(int n, int divisorsSum, int divisorsCount) { // Arrange @@ -19,16 +19,17 @@ public void DivisorsTests(int n, int divisorsSum, int divisorsCount) var divisors = n.Divisors(); // Assert - Assert.That(divisors.Count(), Is.EqualTo(divisorsCount)); - Assert.That(divisors.Sum(), Is.EqualTo(divisorsSum)); + divisors.Count().Should().Be(divisorsCount); + divisors.Sum().Should().Be(divisorsSum); } - [TestCase(1, 0, 0)] - [TestCase(2, 1, 1)] - [TestCase(4, 3, 2)] - [TestCase(16, 15, 4)] - [TestCase(220, 284, 11)] - [TestCase(284, 220, 5)] + [Theory] + [InlineData(1, 0, 0)] + [InlineData(2, 1, 1)] + [InlineData(4, 3, 2)] + [InlineData(16, 15, 4)] + [InlineData(220, 284, 11)] + [InlineData(284, 220, 5)] public void ProperDivisorsTests(int n, int divisorsSum, int divisorsCount) { // Arrange @@ -37,11 +38,12 @@ public void ProperDivisorsTests(int n, int divisorsSum, int divisorsCount) var divisors = n.ProperDivisors(); // Assert - Assert.That(divisors.Count(), Is.EqualTo(divisorsCount)); - Assert.That(divisors.Sum(), Is.EqualTo(divisorsSum)); + divisors.Count().Should().Be(divisorsCount); + divisors.Sum().Should().Be(divisorsSum); } - [TestCase(4, new[] { 1, 2 })] + [Theory] + [InlineData(4, new[] { 1, 2 })] public void ProperDivisors_ValuesTest(int n, int[] expectedDivisors) { var divisors = n.ProperDivisors(); diff --git a/EulerLibTests/Extensions/IntegerExtensionsFixture.cs b/EulerLibTests/Extensions/IntegerExtensionsFixture.cs index 1b9b56d..a7e4677 100644 --- a/EulerLibTests/Extensions/IntegerExtensionsFixture.cs +++ b/EulerLibTests/Extensions/IntegerExtensionsFixture.cs @@ -2,13 +2,13 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class IntegerExtensionsFixture { - [TestCase(2, "2")] - [TestCase(3, "6")] - [TestCase(4, "24")] - [TestCase(5, "120")] + [Theory] + [InlineData(2, "2")] + [InlineData(3, "6")] + [InlineData(4, "24")] + [InlineData(5, "120")] public void FactorialTests(int n, string expectedFactorial) { var result = n.Factorial(); @@ -16,7 +16,7 @@ public void FactorialTests(int n, string expectedFactorial) result.ToString().Should().Be(expectedFactorial); } - [Test] + [Fact] public void DigitRotationsTest2845() { var result = 2845.DigitRotations().ToList(); @@ -24,7 +24,7 @@ public void DigitRotationsTest2845() result.Should().BeEquivalentTo([2845, 8452, 4528, 5284]); } - [Test] + [Fact] public void DigitRotationsTest197() { var result = 197.DigitRotations().ToList(); @@ -32,7 +32,7 @@ public void DigitRotationsTest197() result.Should().BeEquivalentTo([197, 971, 719]); } - [Test] + [Fact] public void DigitRotationsTest111() { var result = 111.DigitRotations().ToList(); diff --git a/EulerLibTests/Extensions/Md5ExtensionsFixture.cs b/EulerLibTests/Extensions/Md5ExtensionsFixture.cs index a61fdd6..573c881 100644 --- a/EulerLibTests/Extensions/Md5ExtensionsFixture.cs +++ b/EulerLibTests/Extensions/Md5ExtensionsFixture.cs @@ -2,10 +2,10 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class Md5ExtensionsFixture { - [TestCase("Hello World!", "ed076287532e86365e841e92bfc50d8c")] + [Theory] + [InlineData("Hello World!", "ed076287532e86365e841e92bfc50d8c")] public void ToMd5Hash(string input, string expectedHash) { var hash = input.ToMd5Hash(); @@ -13,8 +13,9 @@ public void ToMd5Hash(string input, string expectedHash) hash.Should().Be(expectedHash); } - [TestCase("Hello World!", "ed076287532e86365e841e92bfc50d8c", true)] - [TestCase("Hello World!", "ed076287532e86355e841e92bfc50d8c", false)] + [Theory] + [InlineData("Hello World!", "ed076287532e86365e841e92bfc50d8c", true)] + [InlineData("Hello World!", "ed076287532e86355e841e92bfc50d8c", false)] public void VerifyMd5Hash(string input, string hash, bool expectedResult) { var result = input.VerifyMd5Hash(hash); diff --git a/EulerLibTests/Extensions/PrimeFactorsExtensionFixture.cs b/EulerLibTests/Extensions/PrimeFactorsExtensionFixture.cs index 424a73d..9798de9 100644 --- a/EulerLibTests/Extensions/PrimeFactorsExtensionFixture.cs +++ b/EulerLibTests/Extensions/PrimeFactorsExtensionFixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class PrimeFactorsExtensionFixture { - [Test] + [Fact] public void PrimeFactorsOf1() { var sequence = 1.PrimeFactors().ToList(); @@ -13,7 +12,7 @@ public void PrimeFactorsOf1() sequence.Should().BeEmpty(); } - [Test] + [Fact] public void PrimeFactorsOf12() { var sequence = 12.PrimeFactors().ToList(); @@ -21,7 +20,7 @@ public void PrimeFactorsOf12() sequence.Should().BeEquivalentTo(new[] {2, 2, 3}); } - [Test] + [Fact] public void PrimeFactorsOf13195() { var sequence = 13195.PrimeFactors().ToList(); @@ -29,7 +28,7 @@ public void PrimeFactorsOf13195() sequence.Should().BeEquivalentTo(new[] {5, 7, 13, 29}); } - [Test] + [Fact] public void PrimeFactorsOfFirst3500Numbers() { IEnumerable result = null; diff --git a/EulerLibTests/Extensions/RomanNumeralsExtensionsFixture.cs b/EulerLibTests/Extensions/RomanNumeralsExtensionsFixture.cs index 5601bab..1cb2b1d 100644 --- a/EulerLibTests/Extensions/RomanNumeralsExtensionsFixture.cs +++ b/EulerLibTests/Extensions/RomanNumeralsExtensionsFixture.cs @@ -2,11 +2,11 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class RomanNumeralsExtensionsFixture { - [TestCase("XXFX", "F")] - [TestCase("C%C", "%")] + [Theory] + [InlineData("XXFX", "F")] + [InlineData("C%C", "%")] public void ParseRomanNumeral_InvalidRomanCharacter_Throws(string input, string expectedInvalidCharacter) { var ex = Assert.Throws(() => input.ParseRomanNumeral()); @@ -14,12 +14,13 @@ public void ParseRomanNumeral_InvalidRomanCharacter_Throws(string input, string ex.Message.Should().Contain("Invalid Roman numeral character: " + expectedInvalidCharacter); } - [TestCase("I", 1)] - [TestCase("II", 2)] - [TestCase("III", 3)] - [TestCase("IV", 4)] - [TestCase("LVII", 57)] - [TestCase("MMMMCCLXXXVI", 4286)] + [Theory] + [InlineData("I", 1)] + [InlineData("II", 2)] + [InlineData("III", 3)] + [InlineData("IV", 4)] + [InlineData("LVII", 57)] + [InlineData("MMMMCCLXXXVI", 4286)] public void ParseRomanNumeral_ValidInput_ReturnsExpectedResult(string input, int expectedResult) { var result = input.ParseRomanNumeral(); @@ -27,10 +28,11 @@ public void ParseRomanNumeral_ValidInput_ReturnsExpectedResult(string input, int result.Should().Be(expectedResult); } - [TestCase(-5)] - [TestCase(0)] - [TestCase(5000)] - [TestCase(9678)] + [Theory] + [InlineData(-5)] + [InlineData(0)] + [InlineData(5000)] + [InlineData(9678)] public void ToRomanNumeral_OutOfRange_Throws(int value) { var ex = Assert.Throws(() => value.ToRomanNumeral()); @@ -38,11 +40,12 @@ public void ToRomanNumeral_OutOfRange_Throws(int value) ex.Message.Should().Contain("Input must be between 1 and 4999."); } - [TestCase(1, "I")] - [TestCase(2, "II")] - [TestCase(4, "IV")] - [TestCase(19, "XIX")] - [TestCase(2024, "MMXXIV")] + [Theory] + [InlineData(1, "I")] + [InlineData(2, "II")] + [InlineData(4, "IV")] + [InlineData(19, "XIX")] + [InlineData(2024, "MMXXIV")] public void ToRomanNumeral_ValidInput_ReturnsExpectedResult(int value, string expectedResult) { var result = value.ToRomanNumeral(); @@ -50,7 +53,8 @@ public void ToRomanNumeral_ValidInput_ReturnsExpectedResult(int value, string ex result.Should().Be(expectedResult); } - [TestCase("XIIII", "XIV")] + [Theory] + [InlineData("XIIII", "XIV")] public void SimplifyRomanNumeral_ValidInput_ReturnsExpectedOutput(string value, string expectedResult) { var result = value.SimplifyRomanNumeral(); diff --git a/EulerLibTests/Extensions/SequenceMembershipExtensionsFixture.cs b/EulerLibTests/Extensions/SequenceMembershipExtensionsFixture.cs index 349fad3..4376c89 100644 --- a/EulerLibTests/Extensions/SequenceMembershipExtensionsFixture.cs +++ b/EulerLibTests/Extensions/SequenceMembershipExtensionsFixture.cs @@ -2,80 +2,84 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class SequenceMembershipExtensionsFixture { - [TestCase(1, false)] - [TestCase(2, false)] - [TestCase(6, false)] - [TestCase(12, true)] - [TestCase(18, true)] - [TestCase(54, true)] - [TestCase(101, false)] - [TestCase(102, true)] + [Theory] + [InlineData(1, false)] + [InlineData(2, false)] + [InlineData(6, false)] + [InlineData(12, true)] + [InlineData(18, true)] + [InlineData(54, true)] + [InlineData(101, false)] + [InlineData(102, true)] public void IsAbundantTestCases(int n, bool isAbundant) { // AAA - Assert.That(n.IsAbundant(), Is.EqualTo(isAbundant)); + n.IsAbundant().Should().Be(isAbundant); } - [TestCase(1, true)] - [TestCase(2, true)] - [TestCase(6, false)] - [TestCase(12, false)] - [TestCase(18, false)] - [TestCase(53, true)] - [TestCase(101, true)] - [TestCase(102, false)] + [Theory] + [InlineData(1, true)] + [InlineData(2, true)] + [InlineData(6, false)] + [InlineData(12, false)] + [InlineData(18, false)] + [InlineData(53, true)] + [InlineData(101, true)] + [InlineData(102, false)] public void IsDeficientTestCases(int n, bool isDeficient) { // AAA - Assert.That(n.IsDeficient(), Is.EqualTo(isDeficient)); + n.IsDeficient().Should().Be(isDeficient); } - [TestCase(1, false)] - [TestCase(2, false)] - [TestCase(6, true)] - [TestCase(28, true)] - [TestCase(496, true)] - [TestCase(8128, true)] - [TestCase(8130, false)] + [Theory] + [InlineData(1, false)] + [InlineData(2, false)] + [InlineData(6, true)] + [InlineData(28, true)] + [InlineData(496, true)] + [InlineData(8128, true)] + [InlineData(8130, false)] public void IsPerfectTestCases(int n, bool isPerfect) { // AAA - Assert.That(n.IsPerfect(), Is.EqualTo(isPerfect)); + n.IsPerfect().Should().Be(isPerfect); } - [TestCase(1, false)] - [TestCase(2, true)] - [TestCase(3, true)] - [TestCase(4, false)] - [TestCase(5, true)] - [TestCase(7, true)] - [TestCase(9, false)] - [TestCase(11, true)] - [TestCase(13, true)] - [TestCase(15, false)] - [TestCase(17, true)] - [TestCase(19, true)] + [Theory] + [InlineData(1, false)] + [InlineData(2, true)] + [InlineData(3, true)] + [InlineData(4, false)] + [InlineData(5, true)] + [InlineData(7, true)] + [InlineData(9, false)] + [InlineData(11, true)] + [InlineData(13, true)] + [InlineData(15, false)] + [InlineData(17, true)] + [InlineData(19, true)] public void IsPrimeTestCases(int n, bool isPrime) { // AAA - Assert.That(n.IsPrime(), Is.EqualTo(isPrime)); + n.IsPrime().Should().Be(isPrime); } - [TestCase(1, true)] - [TestCase(2, true)] - [TestCase(3, true)] - [TestCase(10, false)] - [TestCase(11, true)] - [TestCase(44, true)] - [TestCase(46, false)] - [TestCase(101, true)] - [TestCase(151, true)] - [TestCase(186, false)] - [TestCase(1016101, true)] - [TestCase(10178663, false)] + [Theory] + [InlineData(1, true)] + [InlineData(2, true)] + [InlineData(3, true)] + [InlineData(10, false)] + [InlineData(11, true)] + [InlineData(44, true)] + [InlineData(46, false)] + [InlineData(101, true)] + [InlineData(151, true)] + [InlineData(186, false)] + [InlineData(1016101, true)] + [InlineData(10178663, false)] public void IsPalindromicTestCases(int n, bool isPalindromic) { n.IsPalindromic().Should().Be(isPalindromic); diff --git a/EulerLibTests/Extensions/StringExtensionsFixture.cs b/EulerLibTests/Extensions/StringExtensionsFixture.cs index 51b0eb9..1275686 100644 --- a/EulerLibTests/Extensions/StringExtensionsFixture.cs +++ b/EulerLibTests/Extensions/StringExtensionsFixture.cs @@ -2,23 +2,24 @@ namespace EulerLibTests.Extensions; -[TestFixture] public class StringExtensionsFixture { - [TestCase("", "")] - [TestCase("a", "a")] - [TestCase("Ian Fraser Nelson", "nosleN resarF naI")] + [Theory] + [InlineData("", "")] + [InlineData("a", "a")] + [InlineData("Ian Fraser Nelson", "nosleN resarF naI")] public void ReverseStringTestCases(string input, string expectedOutput) { input.ReverseString().Should().Be(expectedOutput); } - [TestCase("12321", true)] - [TestCase("1", true)] - [TestCase("333", true)] - [TestCase("4567887654", true)] - [TestCase("12", false)] - [TestCase("345432", false)] + [Theory] + [InlineData("12321", true)] + [InlineData("1", true)] + [InlineData("333", true)] + [InlineData("4567887654", true)] + [InlineData("12", false)] + [InlineData("345432", false)] public void IsPalindromicTestCases(string input, bool expectedIsPalindromic) { input.IsPalindromic().Should().Be(expectedIsPalindromic); diff --git a/EulerLibTests/GlobalUsings.cs b/EulerLibTests/GlobalUsings.cs index 25c79ab..7fef4b0 100644 --- a/EulerLibTests/GlobalUsings.cs +++ b/EulerLibTests/GlobalUsings.cs @@ -1,2 +1,2 @@ -global using NUnit.Framework; +global using Xunit; global using FluentAssertions; \ No newline at end of file diff --git a/EulerLibTests/Monopoly/GameTests.cs b/EulerLibTests/Monopoly/GameTests.cs index c81f1e2..99b70a6 100644 --- a/EulerLibTests/Monopoly/GameTests.cs +++ b/EulerLibTests/Monopoly/GameTests.cs @@ -2,11 +2,9 @@ namespace EulerLibTests.Monopoly; -[TestFixture] public class GameTests { - [Test] - [Ignore("Slow-running")] + [Fact(Skip = "Slow-running")] public void GameTest_SixSidedDice_TopSquaresAreAsExpected() { var game = new Game(6); diff --git a/EulerLibTests/Poker/CardFixture.cs b/EulerLibTests/Poker/CardFixture.cs index 41cae20..8075f56 100644 --- a/EulerLibTests/Poker/CardFixture.cs +++ b/EulerLibTests/Poker/CardFixture.cs @@ -3,22 +3,22 @@ namespace EulerLibTests.Poker; -[TestFixture] public class CardFixture { - [TestCase("2C", Value.Two, Suit.Clubs)] - [TestCase("3H", Value.Three, Suit.Hearts)] - [TestCase("4S", Value.Four, Suit.Spades)] - [TestCase("5D", Value.Five, Suit.Diamonds)] - [TestCase("6C", Value.Six, Suit.Clubs)] - [TestCase("7H", Value.Seven, Suit.Hearts)] - [TestCase("8S", Value.Eight, Suit.Spades)] - [TestCase("9D", Value.Nine, Suit.Diamonds)] - [TestCase("TC", Value.Ten, Suit.Clubs)] - [TestCase("JH", Value.Jack, Suit.Hearts)] - [TestCase("QS", Value.Queen, Suit.Spades)] - [TestCase("KD", Value.King, Suit.Diamonds)] - [TestCase("AC", Value.Ace, Suit.Clubs)] + [Theory] + [InlineData("2C", Value.Two, Suit.Clubs)] + [InlineData("3H", Value.Three, Suit.Hearts)] + [InlineData("4S", Value.Four, Suit.Spades)] + [InlineData("5D", Value.Five, Suit.Diamonds)] + [InlineData("6C", Value.Six, Suit.Clubs)] + [InlineData("7H", Value.Seven, Suit.Hearts)] + [InlineData("8S", Value.Eight, Suit.Spades)] + [InlineData("9D", Value.Nine, Suit.Diamonds)] + [InlineData("TC", Value.Ten, Suit.Clubs)] + [InlineData("JH", Value.Jack, Suit.Hearts)] + [InlineData("QS", Value.Queen, Suit.Spades)] + [InlineData("KD", Value.King, Suit.Diamonds)] + [InlineData("AC", Value.Ace, Suit.Clubs)] public void ValidParseTests(string input, Value expectedValue, Suit expectedSuit) { var card = Card.Parse(input); @@ -27,23 +27,24 @@ public void ValidParseTests(string input, Value expectedValue, Suit expectedSuit card.Value.Should().Be(expectedValue); } - [TestCase("")] - [TestCase(" ")] - [TestCase("2c")] - [TestCase(" 2C")] - [TestCase("2C ")] - [TestCase("2A")] - [TestCase("2B")] - [TestCase("A2")] - [TestCase("0C")] - [TestCase("1C")] - [TestCase("2")] - [TestCase("C")] - [TestCase("2CD")] + [Theory] + [InlineData("")] + [InlineData(" ")] + [InlineData("2c")] + [InlineData(" 2C")] + [InlineData("2C ")] + [InlineData("2A")] + [InlineData("2B")] + [InlineData("A2")] + [InlineData("0C")] + [InlineData("1C")] + [InlineData("2")] + [InlineData("C")] + [InlineData("2CD")] public void InvalidParseTest(string input) { var ex = Assert.Throws(() => Card.Parse(input)); - Assert.That(ex.ParamName, Is.EqualTo("input")); + ex.ParamName.Should().Be("input"); } } \ No newline at end of file diff --git a/EulerLibTests/Poker/HandFixture.cs b/EulerLibTests/Poker/HandFixture.cs index e9592bd..84db81c 100644 --- a/EulerLibTests/Poker/HandFixture.cs +++ b/EulerLibTests/Poker/HandFixture.cs @@ -2,11 +2,11 @@ namespace EulerLibTests.Poker; -[TestFixture] public class HandFixture { - [TestCase("9D 9C AS AH AC")] - [TestCase("2D 8C 2H 8S 2S")] + [Theory] + [InlineData("9D 9C AS AH AC")] + [InlineData("2D 8C 2H 8S 2S")] public void CanIdentifyFullHouse(string input) { var hand = Hand.Parse(input); @@ -14,8 +14,9 @@ public void CanIdentifyFullHouse(string input) hand.Ranking.Should().Be(Ranking.FullHouse); } - [TestCase("2D 9C AS AH AC")] - [TestCase("2D 9C 2H 8S 2S")] + [Theory] + [InlineData("2D 9C AS AH AC")] + [InlineData("2D 9C 2H 8S 2S")] public void CanIdentifyThreeOfAKind(string input) { var hand = Hand.Parse(input); @@ -23,8 +24,9 @@ public void CanIdentifyThreeOfAKind(string input) hand.Ranking.Should().Be(Ranking.ThreeOfAKind); } - [TestCase("AD 9C AS AH AC")] - [TestCase("2D 9C 2H 2C 2S")] + [Theory] + [InlineData("AD 9C AS AH AC")] + [InlineData("2D 9C 2H 2C 2S")] public void CanIdentifyFourOfAKind(string input) { var hand = Hand.Parse(input); @@ -32,8 +34,9 @@ public void CanIdentifyFourOfAKind(string input) hand.Ranking.Should().Be(Ranking.FourOfAKind); } - [TestCase("5D 8C 9S JS AC")] - [TestCase("2C 5C 7D 8S QH")] + [Theory] + [InlineData("5D 8C 9S JS AC")] + [InlineData("2C 5C 7D 8S QH")] public void CanIdentifyHighCard(string input) { var hand = Hand.Parse(input); @@ -41,8 +44,9 @@ public void CanIdentifyHighCard(string input) hand.Ranking.Should().Be(Ranking.HighCard); } - [TestCase("5H 5C 6S 7S KD")] - [TestCase("4D 6S 9H QH QC")] + [Theory] + [InlineData("5H 5C 6S 7S KD")] + [InlineData("4D 6S 9H QH QC")] public void CanIdentifyPair(string input) { var hand = Hand.Parse(input); @@ -50,8 +54,9 @@ public void CanIdentifyPair(string input) hand.Ranking.Should().Be(Ranking.Pair); } - [TestCase("5H 5C 6S 7S 6D")] - [TestCase("9D 6S 9H QH QC")] + [Theory] + [InlineData("5H 5C 6S 7S 6D")] + [InlineData("9D 6S 9H QH QC")] public void CanIdentifyTwoPair(string input) { var hand = Hand.Parse(input); @@ -59,8 +64,9 @@ public void CanIdentifyTwoPair(string input) hand.Ranking.Should().Be(Ranking.TwoPair); } - [TestCase("3D 6D 7D TD QD")] - [TestCase("9S 3S 2S QS KS")] + [Theory] + [InlineData("3D 6D 7D TD QD")] + [InlineData("9S 3S 2S QS KS")] public void CanIdentifyFlush(string input) { var hand = Hand.Parse(input); @@ -68,16 +74,17 @@ public void CanIdentifyFlush(string input) hand.Ranking.Should().Be(Ranking.Flush); } - [TestCase("TD JH QC KS AD")] - [TestCase("9D TH JC QS KD")] - [TestCase("8D 9H TC JS QD")] - [TestCase("7D 8H 9C TS JD")] - [TestCase("6D 7H 8C 9S TD")] - [TestCase("5D 6H 7C 8S 9D")] - [TestCase("4D 5H 6H 7S 8D")] - [TestCase("3S 4H 5C 6S 7D")] - [TestCase("2D 3H 4S 5H 6D")] - [TestCase("AD 2H 3C 4S 5D")] + [Theory] + [InlineData("TD JH QC KS AD")] + [InlineData("9D TH JC QS KD")] + [InlineData("8D 9H TC JS QD")] + [InlineData("7D 8H 9C TS JD")] + [InlineData("6D 7H 8C 9S TD")] + [InlineData("5D 6H 7C 8S 9D")] + [InlineData("4D 5H 6H 7S 8D")] + [InlineData("3S 4H 5C 6S 7D")] + [InlineData("2D 3H 4S 5H 6D")] + [InlineData("AD 2H 3C 4S 5D")] public void CanIdentifyStraight(string input) { var hand = Hand.Parse(input); @@ -85,16 +92,17 @@ public void CanIdentifyStraight(string input) hand.Ranking.Should().Be(Ranking.Straight); } - [TestCase("TD JD QD KD AD")] - [TestCase("9S TS JS QS KS")] - [TestCase("8C 9C TC JC QC")] - [TestCase("7H 8H 9H TH JH")] - [TestCase("6C 7C 8C 9C TC")] - [TestCase("5H 6H 7H 8H 9H")] - [TestCase("4S 5S 6S 7S 8S")] - [TestCase("3D 4D 5D 6D 7D")] - [TestCase("2C 3C 4C 5C 6C")] - [TestCase("AH 2H 3H 4H 5H")] + [Theory] + [InlineData("TD JD QD KD AD")] + [InlineData("9S TS JS QS KS")] + [InlineData("8C 9C TC JC QC")] + [InlineData("7H 8H 9H TH JH")] + [InlineData("6C 7C 8C 9C TC")] + [InlineData("5H 6H 7H 8H 9H")] + [InlineData("4S 5S 6S 7S 8S")] + [InlineData("3D 4D 5D 6D 7D")] + [InlineData("2C 3C 4C 5C 6C")] + [InlineData("AH 2H 3H 4H 5H")] public void CanIdentifyStraightFlush(string input) { var hand = Hand.Parse(input); @@ -102,217 +110,235 @@ public void CanIdentifyStraightFlush(string input) hand.Ranking.Should().Be(Ranking.StraightFlush); } - [TestCase("5H 6H 7H 8H 9H", "AD 9C AS AH AC", 1)] - [TestCase("5H 6H 7H 8H 9H", "2D 8C 2H 8S 2S", 1)] - [TestCase("5H 6H 7H 8H 9H", "9S 3S 2S QS KS", 1)] - [TestCase("5H 6H 7H 8H 9H", "7D 8H 9C TS JD", 1)] - [TestCase("5H 6H 7H 8H 9H", "2D 9C 2H 8S 2S", 1)] - [TestCase("5H 6H 7H 8H 9H", "9D 6S 9H QH QC", 1)] - [TestCase("5H 6H 7H 8H 9H", "4D 6S 9H QH QC", 1)] - [TestCase("5H 6H 7H 8H 9H", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("5H 6H 7H 8H 9H", "AD 9C AS AH AC", 1)] + [InlineData("5H 6H 7H 8H 9H", "2D 8C 2H 8S 2S", 1)] + [InlineData("5H 6H 7H 8H 9H", "9S 3S 2S QS KS", 1)] + [InlineData("5H 6H 7H 8H 9H", "7D 8H 9C TS JD", 1)] + [InlineData("5H 6H 7H 8H 9H", "2D 9C 2H 8S 2S", 1)] + [InlineData("5H 6H 7H 8H 9H", "9D 6S 9H QH QC", 1)] + [InlineData("5H 6H 7H 8H 9H", "4D 6S 9H QH QC", 1)] + [InlineData("5H 6H 7H 8H 9H", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_StraightFlush(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("AD 9C AS AH AC", "5H 6H 7H 8H 9H", -1)] - [TestCase("AD 9C AS AH AC", "2D 8C 2H 8S 2S", 1)] - [TestCase("AD 9C AS AH AC", "9S 3S 2S QS KS", 1)] - [TestCase("AD 9C AS AH AC", "7D 8H 9C TS JD", 1)] - [TestCase("AD 9C AS AH AC", "2D 9C 2H 8S 2S", 1)] - [TestCase("AD 9C AS AH AC", "9D 6S 9H QH QC", 1)] - [TestCase("AD 9C AS AH AC", "4D 6S 9H QH QC", 1)] - [TestCase("AD 9C AS AH AC", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("AD 9C AS AH AC", "5H 6H 7H 8H 9H", -1)] + [InlineData("AD 9C AS AH AC", "2D 8C 2H 8S 2S", 1)] + [InlineData("AD 9C AS AH AC", "9S 3S 2S QS KS", 1)] + [InlineData("AD 9C AS AH AC", "7D 8H 9C TS JD", 1)] + [InlineData("AD 9C AS AH AC", "2D 9C 2H 8S 2S", 1)] + [InlineData("AD 9C AS AH AC", "9D 6S 9H QH QC", 1)] + [InlineData("AD 9C AS AH AC", "4D 6S 9H QH QC", 1)] + [InlineData("AD 9C AS AH AC", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_FourOfAKind(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("2D 8C 2H 8S 2S", "5H 6H 7H 8H 9H", -1)] - [TestCase("2D 8C 2H 8S 2S", "AD 9C AS AH AC", -1)] - [TestCase("2D 8C 2H 8S 2S", "9S 3S 2S QS KS", 1)] - [TestCase("2D 8C 2H 8S 2S", "7D 8H 9C TS JD", 1)] - [TestCase("2D 8C 2H 8S 2S", "2D 9C 2H 8S 2S", 1)] - [TestCase("2D 8C 2H 8S 2S", "9D 6S 9H QH QC", 1)] - [TestCase("2D 8C 2H 8S 2S", "4D 6S 9H QH QC", 1)] - [TestCase("2D 8C 2H 8S 2S", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("2D 8C 2H 8S 2S", "5H 6H 7H 8H 9H", -1)] + [InlineData("2D 8C 2H 8S 2S", "AD 9C AS AH AC", -1)] + [InlineData("2D 8C 2H 8S 2S", "9S 3S 2S QS KS", 1)] + [InlineData("2D 8C 2H 8S 2S", "7D 8H 9C TS JD", 1)] + [InlineData("2D 8C 2H 8S 2S", "2D 9C 2H 8S 2S", 1)] + [InlineData("2D 8C 2H 8S 2S", "9D 6S 9H QH QC", 1)] + [InlineData("2D 8C 2H 8S 2S", "4D 6S 9H QH QC", 1)] + [InlineData("2D 8C 2H 8S 2S", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_FullHouse(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("9S 3S 2S QS KS", "5H 6H 7H 8H 9H", -1)] - [TestCase("9S 3S 2S QS KS", "AD 9C AS AH AC", -1)] - [TestCase("9S 3S 2S QS KS", "2D 8C 2H 8S 2S", -1)] - [TestCase("9S 3S 2S QS KS", "7D 8H 9C TS JD", 1)] - [TestCase("9S 3S 2S QS KS", "2D 9C 2H 8S 2S", 1)] - [TestCase("9S 3S 2S QS KS", "9D 6S 9H QH QC", 1)] - [TestCase("9S 3S 2S QS KS", "4D 6S 9H QH QC", 1)] - [TestCase("9S 3S 2S QS KS", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("9S 3S 2S QS KS", "5H 6H 7H 8H 9H", -1)] + [InlineData("9S 3S 2S QS KS", "AD 9C AS AH AC", -1)] + [InlineData("9S 3S 2S QS KS", "2D 8C 2H 8S 2S", -1)] + [InlineData("9S 3S 2S QS KS", "7D 8H 9C TS JD", 1)] + [InlineData("9S 3S 2S QS KS", "2D 9C 2H 8S 2S", 1)] + [InlineData("9S 3S 2S QS KS", "9D 6S 9H QH QC", 1)] + [InlineData("9S 3S 2S QS KS", "4D 6S 9H QH QC", 1)] + [InlineData("9S 3S 2S QS KS", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_Flush(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("7D 8H 9C TS JD", "5H 6H 7H 8H 9H", -1)] - [TestCase("7D 8H 9C TS JD", "AD 9C AS AH AC", -1)] - [TestCase("7D 8H 9C TS JD", "2D 8C 2H 8S 2S", -1)] - [TestCase("7D 8H 9C TS JD", "9S 3S 2S QS KS", -1)] - [TestCase("7D 8H 9C TS JD", "2D 9C 2H 8S 2S", 1)] - [TestCase("7D 8H 9C TS JD", "9D 6S 9H QH QC", 1)] - [TestCase("7D 8H 9C TS JD", "4D 6S 9H QH QC", 1)] - [TestCase("7D 8H 9C TS JD", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("7D 8H 9C TS JD", "5H 6H 7H 8H 9H", -1)] + [InlineData("7D 8H 9C TS JD", "AD 9C AS AH AC", -1)] + [InlineData("7D 8H 9C TS JD", "2D 8C 2H 8S 2S", -1)] + [InlineData("7D 8H 9C TS JD", "9S 3S 2S QS KS", -1)] + [InlineData("7D 8H 9C TS JD", "2D 9C 2H 8S 2S", 1)] + [InlineData("7D 8H 9C TS JD", "9D 6S 9H QH QC", 1)] + [InlineData("7D 8H 9C TS JD", "4D 6S 9H QH QC", 1)] + [InlineData("7D 8H 9C TS JD", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_Straight(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("2D 9C 2H 8S 2S", "5H 6H 7H 8H 9H", -1)] - [TestCase("2D 9C 2H 8S 2S", "AD 9C AS AH AC", -1)] - [TestCase("2D 9C 2H 8S 2S", "2D 8C 2H 8S 2S", -1)] - [TestCase("2D 9C 2H 8S 2S", "9S 3S 2S QS KS", -1)] - [TestCase("2D 9C 2H 8S 2S", "7D 8H 9C TS JD", -1)] - [TestCase("2D 9C 2H 8S 2S", "9D 6S 9H QH QC", 1)] - [TestCase("2D 9C 2H 8S 2S", "4D 6S 9H QH QC", 1)] - [TestCase("2D 9C 2H 8S 2S", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("2D 9C 2H 8S 2S", "5H 6H 7H 8H 9H", -1)] + [InlineData("2D 9C 2H 8S 2S", "AD 9C AS AH AC", -1)] + [InlineData("2D 9C 2H 8S 2S", "2D 8C 2H 8S 2S", -1)] + [InlineData("2D 9C 2H 8S 2S", "9S 3S 2S QS KS", -1)] + [InlineData("2D 9C 2H 8S 2S", "7D 8H 9C TS JD", -1)] + [InlineData("2D 9C 2H 8S 2S", "9D 6S 9H QH QC", 1)] + [InlineData("2D 9C 2H 8S 2S", "4D 6S 9H QH QC", 1)] + [InlineData("2D 9C 2H 8S 2S", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_ThreeOfAKind(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("9D 6S 9H QH QC", "5H 6H 7H 8H 9H", -1)] - [TestCase("9D 6S 9H QH QC", "AD 9C AS AH AC", -1)] - [TestCase("9D 6S 9H QH QC", "2D 8C 2H 8S 2S", -1)] - [TestCase("9D 6S 9H QH QC", "9S 3S 2S QS KS", -1)] - [TestCase("9D 6S 9H QH QC", "7D 8H 9C TS JD", -1)] - [TestCase("9D 6S 9H QH QC", "2D 9C 2H 8S 2S", -1)] - [TestCase("9D 6S 9H QH QC", "4D 6S 9H QH QC", 1)] - [TestCase("9D 6S 9H QH QC", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("9D 6S 9H QH QC", "5H 6H 7H 8H 9H", -1)] + [InlineData("9D 6S 9H QH QC", "AD 9C AS AH AC", -1)] + [InlineData("9D 6S 9H QH QC", "2D 8C 2H 8S 2S", -1)] + [InlineData("9D 6S 9H QH QC", "9S 3S 2S QS KS", -1)] + [InlineData("9D 6S 9H QH QC", "7D 8H 9C TS JD", -1)] + [InlineData("9D 6S 9H QH QC", "2D 9C 2H 8S 2S", -1)] + [InlineData("9D 6S 9H QH QC", "4D 6S 9H QH QC", 1)] + [InlineData("9D 6S 9H QH QC", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_TwoPair(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("4D 6S 9H QH QC", "5H 6H 7H 8H 9H", -1)] - [TestCase("4D 6S 9H QH QC", "AD 9C AS AH AC", -1)] - [TestCase("4D 6S 9H QH QC", "2D 8C 2H 8S 2S", -1)] - [TestCase("4D 6S 9H QH QC", "9S 3S 2S QS KS", -1)] - [TestCase("4D 6S 9H QH QC", "7D 8H 9C TS JD", -1)] - [TestCase("4D 6S 9H QH QC", "2D 9C 2H 8S 2S", -1)] - [TestCase("4D 6S 9H QH QC", "9D 6S 9H QH QC", -1)] - [TestCase("4D 6S 9H QH QC", "2C 5C 7D 8S QH", 1)] + [Theory] + [InlineData("4D 6S 9H QH QC", "5H 6H 7H 8H 9H", -1)] + [InlineData("4D 6S 9H QH QC", "AD 9C AS AH AC", -1)] + [InlineData("4D 6S 9H QH QC", "2D 8C 2H 8S 2S", -1)] + [InlineData("4D 6S 9H QH QC", "9S 3S 2S QS KS", -1)] + [InlineData("4D 6S 9H QH QC", "7D 8H 9C TS JD", -1)] + [InlineData("4D 6S 9H QH QC", "2D 9C 2H 8S 2S", -1)] + [InlineData("4D 6S 9H QH QC", "9D 6S 9H QH QC", -1)] + [InlineData("4D 6S 9H QH QC", "2C 5C 7D 8S QH", 1)] public void InterRankComparisons_Pair(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("2C 5C 7D 8S QH", "5H 6H 7H 8H 9H", -1)] - [TestCase("2C 5C 7D 8S QH", "AD 9C AS AH AC", -1)] - [TestCase("2C 5C 7D 8S QH", "2D 8C 2H 8S 2S", -1)] - [TestCase("2C 5C 7D 8S QH", "9S 3S 2S QS KS", -1)] - [TestCase("2C 5C 7D 8S QH", "7D 8H 9C TS JD", -1)] - [TestCase("2C 5C 7D 8S QH", "2D 9C 2H 8S 2S", -1)] - [TestCase("2C 5C 7D 8S QH", "9D 6S 9H QH QC", -1)] - [TestCase("2C 5C 7D 8S QH", "4D 6S 9H QH QC", -1)] + [Theory] + [InlineData("2C 5C 7D 8S QH", "5H 6H 7H 8H 9H", -1)] + [InlineData("2C 5C 7D 8S QH", "AD 9C AS AH AC", -1)] + [InlineData("2C 5C 7D 8S QH", "2D 8C 2H 8S 2S", -1)] + [InlineData("2C 5C 7D 8S QH", "9S 3S 2S QS KS", -1)] + [InlineData("2C 5C 7D 8S QH", "7D 8H 9C TS JD", -1)] + [InlineData("2C 5C 7D 8S QH", "2D 9C 2H 8S 2S", -1)] + [InlineData("2C 5C 7D 8S QH", "9D 6S 9H QH QC", -1)] + [InlineData("2C 5C 7D 8S QH", "4D 6S 9H QH QC", -1)] public void InterRankComparisons_HighCard(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("2C KC 7D 8S 5H", "2H QS 7H 8D 5C", 1)] - [TestCase("2H QS 7H 8D 5C", "2C KC 7D 8S 5H", -1)] - [TestCase("2C QC 7D 9S 5H", "2H QS 7H 8D 5C", 1)] - [TestCase("2H QS 7H 8D 5C", "2C QC 7D 9S 5H", -1)] - [TestCase("2C QC 8D 9S 5H", "2H QS 7H 9D 5C", 1)] - [TestCase("2H QS 7H 9D 5C", "2C QC 8D 9S 5H", -1)] - [TestCase("2C QC 8D 9S 6H", "2H QS 8H 9D 5C", 1)] - [TestCase("2H QS 8H 9D 5C", "2C QC 8D 9S 6H", -1)] - [TestCase("3C QC 8D 9S 6H", "2H QS 8H 9D 6C", 1)] - [TestCase("2H QS 8H 9D 6C", "3C QC 8D 9S 6H", -1)] - [TestCase("2H QS 8H 9D 6C", "2C QC 8D 9S 6H", 0)] + [Theory] + [InlineData("2C KC 7D 8S 5H", "2H QS 7H 8D 5C", 1)] + [InlineData("2H QS 7H 8D 5C", "2C KC 7D 8S 5H", -1)] + [InlineData("2C QC 7D 9S 5H", "2H QS 7H 8D 5C", 1)] + [InlineData("2H QS 7H 8D 5C", "2C QC 7D 9S 5H", -1)] + [InlineData("2C QC 8D 9S 5H", "2H QS 7H 9D 5C", 1)] + [InlineData("2H QS 7H 9D 5C", "2C QC 8D 9S 5H", -1)] + [InlineData("2C QC 8D 9S 6H", "2H QS 8H 9D 5C", 1)] + [InlineData("2H QS 8H 9D 5C", "2C QC 8D 9S 6H", -1)] + [InlineData("3C QC 8D 9S 6H", "2H QS 8H 9D 6C", 1)] + [InlineData("2H QS 8H 9D 6C", "3C QC 8D 9S 6H", -1)] + [InlineData("2H QS 8H 9D 6C", "2C QC 8D 9S 6H", 0)] public void IntraRankComparisons_HighCard(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("2C KC 7C 8C 5C", "2H QH 7H 8H 5H", 1)] - [TestCase("2C QC 7C 8C 5C", "2H KH 7H 8H 5H", -1)] - [TestCase("2C QC 7C 9C 5C", "2H QH 7H 8H 5H", 1)] - [TestCase("2C QC 7C 8C 5C", "2H QH 7H 9H 5H", -1)] - [TestCase("2C QC 8C 9C 5C", "2H QH 7H 9H 5H", 1)] - [TestCase("2S QS 7S 9S 5S", "2D QD 8D 9D 5D", -1)] - [TestCase("2S QS 8S 9S 6S", "2D QD 8D 9D 5D", 1)] - [TestCase("2S QS 8S 9S 5S", "2D QD 8D 9D 6D", -1)] - [TestCase("3S QS 8S 9S 6S", "2D QD 8D 9D 6D", 1)] - [TestCase("2S QS 8S 9S 6S", "3D QD 8D 9D 6D", -1)] - [TestCase("2S QS 8S 9S 6S", "2D QD 8D 9D 6D", 0)] + [Theory] + [InlineData("2C KC 7C 8C 5C", "2H QH 7H 8H 5H", 1)] + [InlineData("2C QC 7C 8C 5C", "2H KH 7H 8H 5H", -1)] + [InlineData("2C QC 7C 9C 5C", "2H QH 7H 8H 5H", 1)] + [InlineData("2C QC 7C 8C 5C", "2H QH 7H 9H 5H", -1)] + [InlineData("2C QC 8C 9C 5C", "2H QH 7H 9H 5H", 1)] + [InlineData("2S QS 7S 9S 5S", "2D QD 8D 9D 5D", -1)] + [InlineData("2S QS 8S 9S 6S", "2D QD 8D 9D 5D", 1)] + [InlineData("2S QS 8S 9S 5S", "2D QD 8D 9D 6D", -1)] + [InlineData("3S QS 8S 9S 6S", "2D QD 8D 9D 6D", 1)] + [InlineData("2S QS 8S 9S 6S", "3D QD 8D 9D 6D", -1)] + [InlineData("2S QS 8S 9S 6S", "2D QD 8D 9D 6D", 0)] public void IntraRankComparisons_Flush(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("4D 6S 9H QH QC", "4H 6C 9S JS JD", 1)] - [TestCase("4H 6C 9S JS JD", "4D 6S 9H QH QC", -1)] - [TestCase("4D 6S 9H QH QC", "4H 6C 8S QS QD", 1)] - [TestCase("4H 6C 8S QS QD", "4D 6S 9H QH QC", -1)] - [TestCase("4D 6S 9H QH QC", "4H 5C 9S QS QD", 1)] - [TestCase("4H 5C 9S QS QD", "4D 6S 9H QH QC", -1)] - [TestCase("4D 6S 9H QH QC", "3H 6C 9S QS QD", 1)] - [TestCase("3H 6C 9S QS QD", "4D 6S 9H QH QC", -1)] - [TestCase("4D 6S 9H QH QC", "4H 6C 9S QS QD", 0)] + [Theory] + [InlineData("4D 6S 9H QH QC", "4H 6C 9S JS JD", 1)] + [InlineData("4H 6C 9S JS JD", "4D 6S 9H QH QC", -1)] + [InlineData("4D 6S 9H QH QC", "4H 6C 8S QS QD", 1)] + [InlineData("4H 6C 8S QS QD", "4D 6S 9H QH QC", -1)] + [InlineData("4D 6S 9H QH QC", "4H 5C 9S QS QD", 1)] + [InlineData("4H 5C 9S QS QD", "4D 6S 9H QH QC", -1)] + [InlineData("4D 6S 9H QH QC", "3H 6C 9S QS QD", 1)] + [InlineData("3H 6C 9S QS QD", "4D 6S 9H QH QC", -1)] + [InlineData("4D 6S 9H QH QC", "4H 6C 9S QS QD", 0)] public void IntraRankComparisons_Pair(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("9D 6S 9H QH QC", "9C 6H 9S JS JD", 1)] - [TestCase("9C 6H 9S JS JD", "9D 6S 9H QH QC", -1)] - [TestCase("9D 6S 9H QH QC", "8C 6H 8S QS QD", 1)] - [TestCase("8C 6H 8S QS QD", "9D 6S 9H QH QC", -1)] - [TestCase("9D 6S 9H QH QC", "9C 5H 9S QS QD", 1)] - [TestCase("9C 5H 9S QS QD", "9D 6S 9H QH QC", -1)] - [TestCase("9D 6S 9H QH QC", "9C 6H 9S QS QD", 0)] + [Theory] + [InlineData("9D 6S 9H QH QC", "9C 6H 9S JS JD", 1)] + [InlineData("9C 6H 9S JS JD", "9D 6S 9H QH QC", -1)] + [InlineData("9D 6S 9H QH QC", "8C 6H 8S QS QD", 1)] + [InlineData("8C 6H 8S QS QD", "9D 6S 9H QH QC", -1)] + [InlineData("9D 6S 9H QH QC", "9C 5H 9S QS QD", 1)] + [InlineData("9C 5H 9S QS QD", "9D 6S 9H QH QC", -1)] + [InlineData("9D 6S 9H QH QC", "9C 6H 9S QS QD", 0)] public void IntraRankComparisons_TwoPair(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("3D 9C 3H 8S 3S", "2C 9H 2H 8C 2S", 1)] - [TestCase("2C 9H 2H 8C 2H", "3D 9C 3H 8S 3S", -1)] + [Theory] + [InlineData("3D 9C 3H 8S 3S", "2C 9H 2H 8C 2S", 1)] + [InlineData("2C 9H 2H 8C 2H", "3D 9C 3H 8S 3S", -1)] public void IntraRankComparisons_ThreeOfAKind(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("3D 9C 3H 3S 3C", "2C 9H 2H 2D 2S", 1)] - [TestCase("2C 9H 2H 2D 2S", "3D 9C 3H 3S 3C", -1)] + [Theory] + [InlineData("3D 9C 3H 3S 3C", "2C 9H 2H 2D 2S", 1)] + [InlineData("2C 9H 2H 2D 2S", "3D 9C 3H 3S 3C", -1)] public void IntraRankComparisons_FullHouse(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("3D 3C 3H 8S 3S", "2C 2H 2H 8C 2H", 1)] - [TestCase("2C 2H 2H 8C 2H", "3D 3C 3H 8S 3S", -1)] + [Theory] + [InlineData("3D 3C 3H 8S 3S", "2C 2H 2H 8C 2H", 1)] + [InlineData("2C 2H 2H 8C 2H", "3D 3C 3H 8S 3S", -1)] public void IntraRankComparisons_FourOfAKind(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("TC JS QH KD AC", "9D TH JC QS KH", 1)] - [TestCase("9D TH JC QS KH", "TC JS QH KD AC", -1)] - [TestCase("2C 3S 4H 5D 6C", "AD 2H 3C 4S 5H", 1)] - [TestCase("AD 2H 3C 4S 5D", "2C 3S 4H 5D 6C", -1)] - [TestCase("7D 8H 9C TS JD", "7C 8S 9H TD JC", 0)] + [Theory] + [InlineData("TC JS QH KD AC", "9D TH JC QS KH", 1)] + [InlineData("9D TH JC QS KH", "TC JS QH KD AC", -1)] + [InlineData("2C 3S 4H 5D 6C", "AD 2H 3C 4S 5H", 1)] + [InlineData("AD 2H 3C 4S 5D", "2C 3S 4H 5D 6C", -1)] + [InlineData("7D 8H 9C TS JD", "7C 8S 9H TD JC", 0)] public void IntraRankComparisons_Straight(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); } - [TestCase("TC JC QC KC AC", "9H TH JH QH KH", 1)] - [TestCase("9C TC JC QC KC", "TS JS QS KS AS", -1)] - [TestCase("2S 3S 4S 5S 6S", "AD 2D 3D 4D 5D", 1)] - [TestCase("AD 2D 3D 4D 5D", "2C 3C 4C 5C 6C", -1)] - [TestCase("7H 8H 9H TH JH", "7C 8C 9C TC JC", 0)] + [Theory] + [InlineData("TC JC QC KC AC", "9H TH JH QH KH", 1)] + [InlineData("9C TC JC QC KC", "TS JS QS KS AS", -1)] + [InlineData("2S 3S 4S 5S 6S", "AD 2D 3D 4D 5D", 1)] + [InlineData("AD 2D 3D 4D 5D", "2C 3C 4C 5C 6C", -1)] + [InlineData("7H 8H 9H TH JH", "7C 8C 9C TC JC", 0)] public void IntraRankComparisons_StraightFlush(string handInput, string otherHandInput, int expectedResult) { DoHandComparison(handInput, otherHandInput, expectedResult); @@ -328,7 +354,7 @@ private static void DoHandComparison(string handInput, string otherHandInput, in result.Should().Be(expectedResult); } - [Test] + [Fact] public void ConstructorThrowsIfNoCardsPassed() { var ex = Assert.Throws(() => new Hand([])); @@ -336,7 +362,7 @@ public void ConstructorThrowsIfNoCardsPassed() ex.ParamName.Should().Be("cards"); } - [Test] + [Fact] public void ConstructorThrowsIfNullCardsPassed() { var ex = Assert.Throws(() => new Hand(null)); @@ -344,7 +370,7 @@ public void ConstructorThrowsIfNullCardsPassed() ex.ParamName.Should().Be("cards"); } - [Test] + [Fact] public void ConstructorThrowsIfTooFewCardsPassed() { for (var i = 1; i < 5; i++) @@ -357,7 +383,7 @@ public void ConstructorThrowsIfTooFewCardsPassed() } } - [Test] + [Fact] public void ConstructorThrowsIfTooManyCardsPassed() { for (var i = 6; i < 10; i++) diff --git a/EulerLibTests/Problems/0001_0100/Problem0001Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0001Fixture.cs index 4204329..686e198 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0001Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0001Fixture.cs @@ -3,10 +3,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0001Fixture { - [Test] + [Fact] public void SumMultiplesOfThreeAndFiveBelowTenIs23() { var sut = new Problem0001(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0002Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0002Fixture.cs index 032d03d..c5f412c 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0002Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0002Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0002Fixture { - [Test] + [Fact] public void SumEvenFibonacciWithValuesNotExceeding89Is44() { var sut = new Problem0002(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0003Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0003Fixture.cs index e2caffe..70125d5 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0003Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0003Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0003Fixture { - [Test] + [Fact] public void LargestPrimeFactorOf13195Is29() { var sut = new Problem0003(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0004Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0004Fixture.cs index 703fb0b..5a4b68a 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0004Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0004Fixture.cs @@ -2,12 +2,12 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0004Fixture { - [TestCase(0)] - [TestCase(-1)] - [TestCase(int.MinValue)] + [Theory] + [InlineData(0)] + [InlineData(-1)] + [InlineData(int.MinValue)] public void LargestPalindromeMadeFromProductOfTwoIntegersThrowsIfDigitsIsLessThan1(int digits) { var sut = new Problem0004(); @@ -19,7 +19,7 @@ public void LargestPalindromeMadeFromProductOfTwoIntegersThrowsIfDigitsIsLessTha ex.ParamName.Should().Be("digits"); } - [Test] + [Fact] public void LargestPalindromeMadeFromProductOfTwoIntegersWithDigits2Is9009() { var sut = new Problem0004(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0005Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0005Fixture.cs index 910eea7..5e5934e 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0005Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0005Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0005Fixture { - [Test] + [Fact] public void SmallestIntegerEvenlyDivisibleByNumbersFrom1To10Is2520() { var sut = new Problem0005(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0006Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0006Fixture.cs index 08d095b..0581917 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0006Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0006Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0006Fixture { - [Test] + [Fact] public void SumOfSquaresOfFirst10NaturalsIs385() { var sut = new Problem0006(); @@ -15,7 +14,7 @@ public void SumOfSquaresOfFirst10NaturalsIs385() result.Should().Be(385); } - [Test] + [Fact] public void SquareOfSumsOfFirst10NaturalsIs3025() { var sut = new Problem0006(); @@ -25,7 +24,7 @@ public void SquareOfSumsOfFirst10NaturalsIs3025() result.Should().Be(3025); } - [Test] + [Fact] public void SumSquareDifferenceOfNaturalsUpTo10Is2640() { var sut = new Problem0006(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0007Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0007Fixture.cs index 6ba100b..025d232 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0007Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0007Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0007Fixture { - [Test] + [Fact] public void PrimeInPosition6Is13() { var sut = new Problem0007(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0008Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0008Fixture.cs index d55e4f7..119254c 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0008Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0008Fixture.cs @@ -2,13 +2,13 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0008Fixture { - [TestCase("123", 1, 3)] - [TestCase("123", 2, 6)] - [TestCase("123459", 2, 45)] - [TestCase("593451", 3, 135)] + [Theory] + [InlineData("123", 1, 3)] + [InlineData("123", 2, 6)] + [InlineData("123459", 2, 45)] + [InlineData("593451", 3, 135)] public void LargestProductOfDigitsTests(string text, int digits, int expectedResult) { var sut = new Problem0008(); @@ -18,10 +18,11 @@ public void LargestProductOfDigitsTests(string text, int digits, int expectedRes result.Should().Be(expectedResult); } - [TestCase("7", 7)] - [TestCase("123", 6)] - [TestCase("123459", 1080)] - [TestCase("593451", 2700)] + [Theory] + [InlineData("7", 7)] + [InlineData("123", 6)] + [InlineData("123459", 1080)] + [InlineData("593451", 2700)] public void ProductOfDigitsTests(string text, int expectedResult) { var sut = new Problem0008(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0010Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0010Fixture.cs index 7435281..a471742 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0010Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0010Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0010Fixture { - [Test] + [Fact] public void SumOfPrimesBelow10Is17() { var sut = new Problem0010(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0011Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0011Fixture.cs index 8abfaad..90dfef5 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0011Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0011Fixture.cs @@ -2,28 +2,31 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0011Fixture { - [TestCase("problem0011example2.txt", 2, 945)] + [Theory] + [InlineData("problem0011example2.txt", 2, 945)] public void MaximumProductInAGrid_FindsHorizontals(string filename, int adjacentNumbers, int expectedResult) { DoMaximumProductInAGridTest(filename,adjacentNumbers, expectedResult); } - [TestCase("problem0011example3.txt", 2, 1869)] + [Theory] + [InlineData("problem0011example3.txt", 2, 1869)] public void MaximumProductInAGrid_FindsVerticals(string filename, int adjacentNumbers, int expectedResult) { DoMaximumProductInAGridTest(filename, adjacentNumbers, expectedResult); } - [TestCase("problem0011example1.txt", 2, 4005)] + [Theory] + [InlineData("problem0011example1.txt", 2, 4005)] public void MaximumProductInAGrid_FindsUphillDiagonals(string filename, int adjacentNumbers, int expectedResult) { DoMaximumProductInAGridTest(filename, adjacentNumbers, expectedResult); } - [TestCase("problem0011example4.txt", 2, 4320)] + [Theory] + [InlineData("problem0011example4.txt", 2, 4320)] public void MaximumProductInAGrid_FindsDownhillDiagonals(string filename, int adjacentNumbers, int expectedResult) { DoMaximumProductInAGridTest(filename, adjacentNumbers, expectedResult); diff --git a/EulerLibTests/Problems/0001_0100/Problem0012Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0012Fixture.cs index a1212ae..c20b3bb 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0012Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0012Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems { - [TestFixture] public class Problem0012Fixture { - [Test] + [Fact] public void FirstTriangularNumberToHaveOverFiveDivisorsIs28() { var sut = new Problem0012(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0014Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0014Fixture.cs index b83d759..53c9a07 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0014Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0014Fixture.cs @@ -2,12 +2,12 @@ namespace EulerLibTests.Problems { - [TestFixture] public class Problem0014Fixture { - [TestCase(2)] - [TestCase(5)] - [TestCase(50)] + [Theory] + [InlineData(2)] + [InlineData(5)] + [InlineData(50)] public void CollatzChainTerms_EntryForEachIntegerAboveTwo(int maximumStartingNumber) { // Arrange @@ -20,7 +20,8 @@ public void CollatzChainTerms_EntryForEachIntegerAboveTwo(int maximumStartingNum terms.Count.Should().Be(maximumStartingNumber - 1); } - [TestCase(13,10)] + [Theory] + [InlineData(13,10)] public void CollatzChainTerms_ContainsExpectedResults(int startingNumber, int expectedTerms) { // Arrange diff --git a/EulerLibTests/Problems/0001_0100/Problem0015Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0015Fixture.cs index f47c10e..ad2fed2 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0015Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0015Fixture.cs @@ -2,11 +2,11 @@ namespace EulerLibTests.Problems { - [TestFixture] public class Problem0015Fixture { - [TestCase(2,6)] - [TestCase(3, 20)] + [Theory] + [InlineData(2,6)] + [InlineData(3, 20)] public void PathsThroughGridWithSideLength(int sideLength, long expectedPaths) { var sut = new Problem0015(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0016Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0016Fixture.cs index 7da10b1..b8def8b 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0016Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0016Fixture.cs @@ -2,12 +2,12 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0016Fixture { - [TestCase(3, 2,9)] - [TestCase(4,3,10)] - [TestCase(2,15,26)] + [Theory] + [InlineData(3, 2,9)] + [InlineData(4,3,10)] + [InlineData(2,15,26)] public void PowerDigitSumTests(int value, int exponent, int expectedSum) { var sut = new Problem0016(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0018Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0018Fixture.cs index 405d59d..6c80dfb 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0018Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0018Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0018Fixture { - [Test] + [Fact] public void MaxSumThroughSampleIs23() { var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles/problem0018example.txt"); diff --git a/EulerLibTests/Problems/0001_0100/Problem0025Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0025Fixture.cs index d6b2e01..4055cd1 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0025Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0025Fixture.cs @@ -2,10 +2,10 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0025Fixture { - [TestCase(3, 12)] + [Theory] + [InlineData(3, 12)] public void IndexOfFirstFibonacciNumberToContainNDigitsTests(int n, int expectedIndex) { var sut = new Problem0025(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0026Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0026Fixture.cs index d2a2699..973b276 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0026Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0026Fixture.cs @@ -2,18 +2,18 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0026Fixture { - [TestCase(2, 0)] - [TestCase(3, 1)] - [TestCase(4, 0)] - [TestCase(5, 0)] - [TestCase(6, 1)] - [TestCase(7, 6)] - [TestCase(8, 0)] - [TestCase(9, 1)] - [TestCase(10, 0)] + [Theory] + [InlineData(2, 0)] + [InlineData(3, 1)] + [InlineData(4, 0)] + [InlineData(5, 0)] + [InlineData(6, 1)] + [InlineData(7, 6)] + [InlineData(8, 0)] + [InlineData(9, 1)] + [InlineData(10, 0)] public void ReciprocalCycleLength_Tests(int denominator, int expectedCycleLength) { var cycleLength = Problem0026.ReciprocalCycleLength(denominator); @@ -21,8 +21,9 @@ public void ReciprocalCycleLength_Tests(int denominator, int expectedCycleLength cycleLength.Should().Be(expectedCycleLength); } - [TestCase(4, 3)] - [TestCase(10, 7)] + [Theory] + [InlineData(4, 3)] + [InlineData(10, 7)] public void MaximumReciprocalCycleLengthTest(int maximumDenomator, int expectedMaximumCycleLength) { var cycleLength = Problem0026.DenominatorWIthMaximumReciprocalCycleLength(maximumDenomator); diff --git a/EulerLibTests/Problems/0001_0100/Problem0028Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0028Fixture.cs index d29831c..0c4f735 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0028Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0028Fixture.cs @@ -2,12 +2,12 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0028Fixture { - [TestCase(1, 1)] - [TestCase(3, 25)] - [TestCase(5, 101)] + [Theory] + [InlineData(1, 1)] + [InlineData(3, 25)] + [InlineData(5, 101)] public void SumOfDiagonals_Tests(int numberSpiralSize, int expectedSumOfDiagonals) { var sumOfDiagonals = Problem0028.SumOfDiagonals(numberSpiralSize); diff --git a/EulerLibTests/Problems/0001_0100/Problem0029Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0029Fixture.cs index b34acf2..c2c8568 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0029Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0029Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0029Fixture { - [Test] + [Fact] public void DistinctPowersThrough5Gives15DistinctTerms() { var count = Problem0029.CountDistinctPowersThrough(5); diff --git a/EulerLibTests/Problems/0001_0100/Problem0030Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0030Fixture.cs index cb316a5..c4fcb70 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0030Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0030Fixture.cs @@ -2,10 +2,10 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0030Fixture { - [TestCase(4,19316)] + [Theory] + [InlineData(4,19316)] public void SumOfNumbersThatCanBeWrittenAsSumOfNthPower_Tests(int n, int expectedSum) { var sum = Problem0030.SumOfNumbersThatCanBeBeWrittenAsSumOfNthPowerOfDigits(4); diff --git a/EulerLibTests/Problems/0001_0100/Problem0031Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0031Fixture.cs index 51327b8..a5cea02 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0031Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0031Fixture.cs @@ -2,15 +2,15 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0031Fixture { - [TestCase(1, 1)] - [TestCase(2, 2)] - [TestCase(3, 2)] - [TestCase(4, 3)] - [TestCase(5, 4)] - [TestCase(10, 11)] + [Theory] + [InlineData(1, 1)] + [InlineData(2, 2)] + [InlineData(3, 2)] + [InlineData(4, 3)] + [InlineData(5, 4)] + [InlineData(10, 11)] public void WaysOfMakingTests(int n, int expectedWays) { var sut = new Problem0031(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0037Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0037Fixture.cs index e431f21..1c5df0d 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0037Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0037Fixture.cs @@ -2,15 +2,14 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0037Fixture { - [Test] + [Fact] public void GetTruncatedValuesTest() { var list = Problem0037.GetTruncatedValues(3797).ToList(); - Assert.That(list.Count, Is.EqualTo(6)); - Assert.That(list.Sum(), Is.EqualTo(1320)); + list.Count.Should().Be(6); + list.Sum().Should().Be(1320); } } \ No newline at end of file diff --git a/EulerLibTests/Problems/0001_0100/Problem0043Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0043Fixture.cs index d327b20..cbc4948 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0043Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0043Fixture.cs @@ -3,26 +3,19 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0043Fixture { - private Problem0043 _sut; - - [SetUp] - public void SetUp() - { - _sut = new Problem0043(); - } - - [TestCase("1406357289")] - [TestCase("1430952867")] + [Theory] + [InlineData("1406357289")] + [InlineData("1430952867")] public void HasDesiredProperty_PositiveExamples(string pandigital) { Problem0043.HasDesiredProperty(pandigital).Should().BeTrue(); } - [TestCase("1406357892")] - [TestCase("0123456789")] + [Theory] + [InlineData("1406357892")] + [InlineData("0123456789")] public void HasDesiredProperty_NegativeExamples(string pandigital) { Problem0043.HasDesiredProperty(pandigital).Should().BeFalse(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0047Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0047Fixture.cs index 2041296..e4b616e 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0047Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0047Fixture.cs @@ -2,14 +2,14 @@ namespace EulerLibTests.Problems { - [TestFixture] public class Problem0047Fixture { - [TestCase(14, 2)] - [TestCase(15, 2)] - [TestCase(644, 3)] - [TestCase(645, 3)] - [TestCase(646, 3)] + [Theory] + [InlineData(14, 2)] + [InlineData(15, 2)] + [InlineData(644, 3)] + [InlineData(645, 3)] + [InlineData(646, 3)] public void DistinctPrimeFactorCount(int x, int expectedValue) { var sut = new Problem0047(); @@ -19,9 +19,10 @@ public void DistinctPrimeFactorCount(int x, int expectedValue) actual.Should().Be(expectedValue); } - [TestCase(2, 14)] - [TestCase(3, 644)] - [TestCase(4, 134043)] + [Theory] + [InlineData(2, 14)] + [InlineData(3, 644)] + [InlineData(4, 134043)] public void FirstOfNConsecutiveIntegersWithNDistinctPrimeFactors(int n, int expectedValue) { var sut = new Problem0047(); diff --git a/EulerLibTests/Problems/0001_0100/Problem0054Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0054Fixture.cs index e9d9063..73813af 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0054Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0054Fixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0054Fixture { - [Test] + [Fact] public void Player1Wins3HandsInExample() { var file = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "TestFiles/problem0054example.txt"); diff --git a/EulerLibTests/Problems/0001_0100/Problem0055Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0055Fixture.cs index b53f145..a3bcf06 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0055Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0055Fixture.cs @@ -2,14 +2,14 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0055Fixture { - [TestCase(3, false)] - [TestCase(47, false)] - [TestCase(349,false)] - [TestCase(196,true)] - [TestCase(4994, true)] + [Theory] + [InlineData(3, false)] + [InlineData(47, false)] + [InlineData(349,false)] + [InlineData(196,true)] + [InlineData(4994, true)] public void IsLychrelTests(int n, bool expectedValue) { var actual = Problem0055.IsLychrel(n); diff --git a/EulerLibTests/Problems/0001_0100/Problem0092Fixture.cs b/EulerLibTests/Problems/0001_0100/Problem0092Fixture.cs index b8d5aa2..9775e4d 100644 --- a/EulerLibTests/Problems/0001_0100/Problem0092Fixture.cs +++ b/EulerLibTests/Problems/0001_0100/Problem0092Fixture.cs @@ -2,26 +2,27 @@ namespace EulerLibTests.Problems; -[TestFixture] public class Problem0092Fixture { - [TestCase(85, 89)] - [TestCase(89, 145)] - [TestCase(145, 42)] - [TestCase(42, 20)] - [TestCase(20, 4)] + [Theory] + [InlineData(85, 89)] + [InlineData(89, 145)] + [InlineData(145, 42)] + [InlineData(42, 20)] + [InlineData(20, 4)] public void SumOfSquareOfDigitsTest(int number, int expectedSumOfSquareOfDigits) { Problem0092.SumOfSquareOfDigits(number).Should().Be(expectedSumOfSquareOfDigits); } - [TestCase(44, 1)] - [TestCase(32, 1)] - [TestCase(10, 1)] - [TestCase(1, 1)] - [TestCase(89, 89)] - [TestCase(85, 89)] - [TestCase(145, 89)] + [Theory] + [InlineData(44, 1)] + [InlineData(32, 1)] + [InlineData(10, 1)] + [InlineData(1, 1)] + [InlineData(89, 89)] + [InlineData(85, 89)] + [InlineData(145, 89)] public void EndValue(int number, int expectedEndValue) { var sut = new Problem0092(); diff --git a/EulerLibTests/Sequences/AbundantNumbersFixture.cs b/EulerLibTests/Sequences/AbundantNumbersFixture.cs index a05c83a..1225683 100644 --- a/EulerLibTests/Sequences/AbundantNumbersFixture.cs +++ b/EulerLibTests/Sequences/AbundantNumbersFixture.cs @@ -2,23 +2,23 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class AbundantNumbersFixture { - [TestCase(0, 12)] - [TestCase(1, 18)] - [TestCase(2, 20)] - [TestCase(3, 24)] - [TestCase(4, 30)] + [Theory] + [InlineData(0, 12)] + [InlineData(1, 18)] + [InlineData(2, 20)] + [InlineData(3, 24)] + [InlineData(4, 30)] public void AbundantTestCases(int index, int value) { var sequence = new AbundantNumbers().GenerateToMaximumSize(index+1).ToList(); - Assert.That(sequence.Count, Is.EqualTo(index+1)); - Assert.That(sequence[index], Is.EqualTo(value)); + sequence.Count.Should().Be(index+1); + sequence[index].Should().Be(value); } - [Test] + [Fact] public void AbundantTestCases_UsingGenerateToMaximumValue() { var sequence = new AbundantNumbers().GenerateToMaximumValue(30); diff --git a/EulerLibTests/Sequences/DeficientNumbersFixture.cs b/EulerLibTests/Sequences/DeficientNumbersFixture.cs index c903e4c..a182e0b 100644 --- a/EulerLibTests/Sequences/DeficientNumbersFixture.cs +++ b/EulerLibTests/Sequences/DeficientNumbersFixture.cs @@ -2,23 +2,23 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class DeficientNumbersFixture { - [TestCase(0, 1)] - [TestCase(1, 2)] - [TestCase(2, 3)] - [TestCase(3, 4)] - [TestCase(4, 5)] - [TestCase(5, 7)] - [TestCase(10, 13)] - [TestCase(15, 19)] - [TestCase(17, 22)] - [TestCase(20, 26)] + [Theory] + [InlineData(0, 1)] + [InlineData(1, 2)] + [InlineData(2, 3)] + [InlineData(3, 4)] + [InlineData(4, 5)] + [InlineData(5, 7)] + [InlineData(10, 13)] + [InlineData(15, 19)] + [InlineData(17, 22)] + [InlineData(20, 26)] public void DeficientsTestCases(int index, int value) { var sequence = new DeficientNumbers().GenerateToMaximumSize(21); - Assert.That(sequence.ElementAt(index), Is.EqualTo(value)); + sequence.ElementAt(index).Should().Be(value); } } \ No newline at end of file diff --git a/EulerLibTests/Sequences/FibonacciNumbersFixture.cs b/EulerLibTests/Sequences/FibonacciNumbersFixture.cs index 8dbbb9c..6a4cdb7 100644 --- a/EulerLibTests/Sequences/FibonacciNumbersFixture.cs +++ b/EulerLibTests/Sequences/FibonacciNumbersFixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class FibonacciNumbersFixture { - [Test] + [Fact] public void FibonacciTest_GenerateToMaximumSize() { var sequence = new FibonacciNumbers().GenerateToMaximumSize(10); @@ -13,7 +12,7 @@ public void FibonacciTest_GenerateToMaximumSize() sequence.Should().BeEquivalentTo(new[] { 1, 2, 3, 5, 8, 13, 21, 34, 55, 89 }); } - [Test] + [Fact] public void FibonacciTest_GenerateToMaximumValue() { var sequence = new FibonacciNumbers().GenerateToMaximumValue(50); diff --git a/EulerLibTests/Sequences/HexagonalNumbersFixture.cs b/EulerLibTests/Sequences/HexagonalNumbersFixture.cs index 44bd813..130ee9a 100644 --- a/EulerLibTests/Sequences/HexagonalNumbersFixture.cs +++ b/EulerLibTests/Sequences/HexagonalNumbersFixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class HexagonalNumbersFixture { - [Test] + [Fact] public void HexagonalNumbers_GenerateToMaximumSize() { var sequence = new HexagonalNumbers().GenerateToMaximumSize(5); @@ -13,7 +12,7 @@ public void HexagonalNumbers_GenerateToMaximumSize() sequence.Should().BeEquivalentTo([1, 6, 15, 28, 45]); } - [Test] + [Fact] public void HexagonalNumbers_GenerateToMaximumValue() { var sequence = new HexagonalNumbers().GenerateToMaximumValue(40); diff --git a/EulerLibTests/Sequences/PentagonalNumbersFixture.cs b/EulerLibTests/Sequences/PentagonalNumbersFixture.cs index a0e6475..a2a6f36 100644 --- a/EulerLibTests/Sequences/PentagonalNumbersFixture.cs +++ b/EulerLibTests/Sequences/PentagonalNumbersFixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class PentagonalNumbersFixture { - [Test] + [Fact] public void PentagonalNumbers_GenerateToMaximumSize() { var sequence = new PentagonalNumbers().GenerateToMaximumSize(10); @@ -13,7 +12,7 @@ public void PentagonalNumbers_GenerateToMaximumSize() sequence.Should().BeEquivalentTo([1, 5, 12, 22, 35, 51, 70, 92, 117, 145]); } - [Test] + [Fact] public void PentagonalNumbers_GenerateToMaximumValue() { var sequence = new PentagonalNumbers().GenerateToMaximumValue(22); diff --git a/EulerLibTests/Sequences/PerfectNumberFixture.cs b/EulerLibTests/Sequences/PerfectNumberFixture.cs index 93cd7e7..00e60ba 100644 --- a/EulerLibTests/Sequences/PerfectNumberFixture.cs +++ b/EulerLibTests/Sequences/PerfectNumberFixture.cs @@ -2,15 +2,15 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class PerfectNumbersFixture { - [TestCase(0, 6)] - [TestCase(1, 28)] + [Theory] + [InlineData(0, 6)] + [InlineData(1, 28)] public void AbundantsTestCases(int index, int value) { var sequence = new PerfectNumbers().GenerateToMaximumSize(2); - Assert.That(sequence.ElementAt(index), Is.EqualTo(value)); + sequence.ElementAt(index).Should().Be(value); } } \ No newline at end of file diff --git a/EulerLibTests/Sequences/PrimeNumbersFixture.cs b/EulerLibTests/Sequences/PrimeNumbersFixture.cs index 8bc8f4f..ceb7169 100644 --- a/EulerLibTests/Sequences/PrimeNumbersFixture.cs +++ b/EulerLibTests/Sequences/PrimeNumbersFixture.cs @@ -2,46 +2,48 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class PrimeNumbersFixture { - [TestCase(0, 2)] - [TestCase(1, 3)] - [TestCase(2, 5)] - [TestCase(3, 7)] - [TestCase(4, 11)] + [Theory] + [InlineData(0, 2)] + [InlineData(1, 3)] + [InlineData(2, 5)] + [InlineData(3, 7)] + [InlineData(4, 11)] public void PrimesTestCases(int index, int value) { var sequence = new PrimeNumbers().GenerateToMaximumSize(5); - Assert.That(sequence.ElementAt(index), Is.EqualTo(value)); + sequence.ElementAt(index).Should().Be(value); } - [TestCase(50, 47)] - [TestCase(40, 37)] - [TestCase(30, 29)] - [TestCase(19, 19)] + [Theory] + [InlineData(50, 47)] + [InlineData(40, 37)] + [InlineData(30, 29)] + [InlineData(19, 19)] public void GenerateToMaximumValueTests(int maximumValue, int lastPrime) { var sequence = new PrimeNumbers().GenerateToMaximumValue(maximumValue).ToList(); - Assert.That(sequence.Last(), Is.EqualTo(lastPrime)); + sequence.Last().Should().Be(lastPrime); } - [TestCase(5, 11)] - [TestCase(10, 29)] - [TestCase(15, 47)] - [TestCase(20, 71)] - [TestCase(100, 541)] - [TestCase(20000,224737)] + [Theory] + [InlineData(5, 11)] + [InlineData(10, 29)] + [InlineData(15, 47)] + [InlineData(20, 71)] + [InlineData(100, 541)] + [InlineData(20000,224737)] public void GenerateToMaximumSizeTests(int maximumSize, int lastPrime) { var sequence = new PrimeNumbers().GenerateToMaximumSize(maximumSize).ToList(); - Assert.That(sequence.Last(), Is.EqualTo(lastPrime)); + sequence.Last().Should().Be(lastPrime); } - [Test] + [Fact] public void GenerateUsingEratosthenesSieveTest1() { var sequence = new PrimeNumbers().GenerateUsingEratosthenesSieve(20).ToList(); @@ -49,7 +51,7 @@ public void GenerateUsingEratosthenesSieveTest1() sequence.Should().BeEquivalentTo(new[] { 2, 3, 5, 7, 11, 13, 17, 19 }); } - [Test] + [Fact] public void GenerateUsingEratosthenesSieveTest2() { var sequence = new PrimeNumbers().GenerateUsingEratosthenesSieve(30).ToList(); diff --git a/EulerLibTests/Sequences/SquareNumbersFixture.cs b/EulerLibTests/Sequences/SquareNumbersFixture.cs index 63c7190..02c3706 100644 --- a/EulerLibTests/Sequences/SquareNumbersFixture.cs +++ b/EulerLibTests/Sequences/SquareNumbersFixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class SquareNumbersFixture { - [Test] + [Fact] public void SquareNumbers_GenerateToMaximumSize() { var sequence = new SquareNumbers().GenerateToMaximumSize(10); @@ -13,7 +12,7 @@ public void SquareNumbers_GenerateToMaximumSize() sequence.Should().BeEquivalentTo([1, 4, 9, 16, 25, 36, 49, 64, 81, 100]); } - [Test] + [Fact] public void PentagonalNumbers_GenerateToMaximumValue() { var sequence = new SquareNumbers().GenerateToMaximumValue(80); diff --git a/EulerLibTests/Sequences/TriangularNumbersFixture.cs b/EulerLibTests/Sequences/TriangularNumbersFixture.cs index 8bb3856..00b38be 100644 --- a/EulerLibTests/Sequences/TriangularNumbersFixture.cs +++ b/EulerLibTests/Sequences/TriangularNumbersFixture.cs @@ -2,10 +2,9 @@ namespace EulerLibTests.Sequences; -[TestFixture] public class TriangularNumbersFixture { - [Test] + [Fact] public void TriangularNumbers_GenerateToMaximumSize() { var sequence = new TriangularNumbers().GenerateToMaximumSize(10); @@ -13,7 +12,7 @@ public void TriangularNumbers_GenerateToMaximumSize() sequence.Should().BeEquivalentTo(new[] { 1, 3, 6, 10, 15, 21, 28, 36, 45, 55 }); } - [Test] + [Fact] public void TriangularNumbers_GenerateToMaximumValue() { var sequence = new TriangularNumbers().GenerateToMaximumValue(22); diff --git a/EulerLibTests/Sets/PandigitalNumbersFixture.cs b/EulerLibTests/Sets/PandigitalNumbersFixture.cs index 9d83b63..199241c 100644 --- a/EulerLibTests/Sets/PandigitalNumbersFixture.cs +++ b/EulerLibTests/Sets/PandigitalNumbersFixture.cs @@ -3,28 +3,27 @@ namespace EulerLibTests.Sets; -[TestFixture] public class PandigitalNumbersFixture { - [Test] + [Fact] public void GetPandigitalNumbers_startDigit1_endDigit1_Returns1() { PandigitalNumbers.Generate(1,1).Should().BeEquivalentTo("1"); } - [Test] + [Fact] public void GetPandigitalNumbers_startDigit1_endDigit2_Returns12And21() { PandigitalNumbers.Generate(1,2).Should().BeEquivalentTo("12", "21"); } - [Test] + [Fact] public void GetPandigitalNumbers_startDigit1_endDigit3_ReturnsExpectedSixNumbers() { PandigitalNumbers.Generate(1,3).Should().BeEquivalentTo("123", "132", "213", "231", "312", "321"); } - [Test] + [Fact] public void GetPandigitalNumbers_startDigit4_endDigit6_ReturnsExpectedSixNumbers() { PandigitalNumbers.Generate(4,6).Should().BeEquivalentTo("456", "465", "546", "564", "645", "654"); diff --git a/EulerLibTests/SoakTestFixture.cs b/EulerLibTests/SoakTestFixture.cs index f0c97f5..dd81629 100644 --- a/EulerLibTests/SoakTestFixture.cs +++ b/EulerLibTests/SoakTestFixture.cs @@ -4,10 +4,9 @@ namespace EulerLibTests; -[TestFixture] public class SoakTestFixture { - [Test] + [Fact] public void RunAllSolvedProblems() { // Get All Problems @@ -33,9 +32,9 @@ public void RunAllSolvedProblems() } } - if (failures.Count != 0) - { - Assert.Fail(string.Join(Environment.NewLine, failures)); - } + failures.Should().BeEmpty( + because: failures.Count > 0 + ? string.Join(Environment.NewLine, failures) + : string.Empty); } } \ No newline at end of file