From e5c1c4e0eca339cab19827a40a9345515dddb7fd Mon Sep 17 00:00:00 2001 From: Nikolay Kostov Date: Sat, 1 Aug 2020 17:07:29 +0300 Subject: [PATCH] Fix failing unit tests --- .../TexasHoldem.Logic.Tests/AssertExtensions.cs | 15 +++++++++++++++ .../TexasHoldem.Logic.Tests/Cards/DeckTests.cs | 2 +- .../Helpers/HandEvaluatorTests.cs | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 Source/Tests/TexasHoldem.Logic.Tests/AssertExtensions.cs diff --git a/Source/Tests/TexasHoldem.Logic.Tests/AssertExtensions.cs b/Source/Tests/TexasHoldem.Logic.Tests/AssertExtensions.cs new file mode 100644 index 0000000..cfd67f6 --- /dev/null +++ b/Source/Tests/TexasHoldem.Logic.Tests/AssertExtensions.cs @@ -0,0 +1,15 @@ +namespace TexasHoldem.Logic.Tests +{ + using System.Collections.Generic; + using System.Linq; + + using Xunit; + + public static class CollectionsAssert + { + public static void SameElements(IEnumerable expected, IEnumerable actual) + { + Assert.True(!expected.Except(actual).Any() && expected.Count() == actual.Count()); + } + } +} diff --git a/Source/Tests/TexasHoldem.Logic.Tests/Cards/DeckTests.cs b/Source/Tests/TexasHoldem.Logic.Tests/Cards/DeckTests.cs index 1ff3643..1646df7 100644 --- a/Source/Tests/TexasHoldem.Logic.Tests/Cards/DeckTests.cs +++ b/Source/Tests/TexasHoldem.Logic.Tests/Cards/DeckTests.cs @@ -30,7 +30,7 @@ public void GetNextCardShouldReturnAll52CardsOnce() cards.Add(deck.GetNextCard()); } - Assert.Equal(Deck.AllCards, cards); + CollectionsAssert.SameElements(Deck.AllCards, cards); } [Fact] diff --git a/Source/Tests/TexasHoldem.Logic.Tests/Helpers/HandEvaluatorTests.cs b/Source/Tests/TexasHoldem.Logic.Tests/Helpers/HandEvaluatorTests.cs index ebd654b..1e562c2 100644 --- a/Source/Tests/TexasHoldem.Logic.Tests/Helpers/HandEvaluatorTests.cs +++ b/Source/Tests/TexasHoldem.Logic.Tests/Helpers/HandEvaluatorTests.cs @@ -674,7 +674,7 @@ public void GetRankTypeShouldWorkCorrectly(ICollection playerCards, HandRa IHandEvaluator handEvaluator = new HandEvaluator(); var bestHand = handEvaluator.GetBestHand(playerCards.Shuffle().ToList()); Assert.Equal(expectedHandRankType, bestHand.RankType); - Assert.Equal(expectedBestHandCards, bestHand.Cards); + CollectionsAssert.SameElements(expectedBestHandCards, bestHand.Cards); } } }