public void Get_rank_by_name_returns_null() { var rank = new Rank("king", 13); var set = new RankSet(new[] { rank }); var result = set["ace"]; Assert.IsNull(result); }
public void Get_rank_by_name_returns_ignoring_case() { var rank = new Rank("king", 13); var set = new RankSet(new[] { rank }); var result = set["King"]; Assert.AreSame(result, rank); }
public GameTests() { _suitset = SuitSet.From <FrenchSuits>(s => s == FrenchSuits.Hearts || s == FrenchSuits.Diamonds ? Color.Red : Color.Black); _rankset = new RankSet(new[] { new Rank("r1", 1), new Rank("r2", 2), new Rank("r3", 3), new Rank("r4", 4, true) }); }
public Game(RankSet ranks, SuitSet suits, Rules rules, Parties parties) { RankSet = ranks; SuitSet = suits; Rules = rules; Table = new Table(Rules.ZoneFactory); Parties = parties; Round = new Round(Table, rules, parties); EnsurePartiesValid(parties); }
public void Ctor_MakesPileWithAllPossibleCardsOrdered() { var suitSet = new SuitSet(new[] { new Suit("s1", Color.Black), new Suit("s2", Color.Black) }); var rankSet = new RankSet(new[] { new Rank("r1", 1), new Rank("r2", 2, true) }); var pack = new Pack(suitSet, rankSet, shuffle: false); var expectedPackSize = suitSet.Count * rankSet.Count; Assert.AreEqual(expectedPackSize, pack.Size); CollectionAssert.AreEqual(rankSet, pack.Where(x => x.Suit == suitSet[0]).Select(x => x.Rank)); CollectionAssert.AreEqual(suitSet, pack.Where(x => x.Rank == rankSet[0]).Select(x => x.Suit)); }
[Retry(3)] // due to random of shuffle public void Ctor_WhenShuffle_MakesPileWithAllPossibleCardsShuffled() { var suitSet = new SuitSet(new[] { new Suit("s1", Color.Black), new Suit("s2", Color.Black) }); var rankSet = new RankSet(new[] { new Rank("r1", 1), new Rank("r2", 2, true) }); var pack = new Pack(suitSet, rankSet, shuffle: true); Assert.AreEqual(suitSet.Count * rankSet.Count, pack.Size); CollectionAssert.AreNotEqual(new[] { new Card(rankSet[0], suitSet[0]), new Card(rankSet[0], suitSet[0]), new Card(rankSet[1], suitSet[0]), new Card(rankSet[1], suitSet[0]), new Card(rankSet[0], suitSet[1]) }, pack.Take(5)); }
public void Ctor_WhenManyDecks_MakesPileWithAllPossibleCardsOrdered() { var suitSet = new SuitSet(new[] { new Suit("s1", Color.Black), new Suit("s2", Color.Black) }); var rankSet = new RankSet(new[] { new Rank("r1", 1), new Rank("r2", 2, true) }); var decksCount = 2; var pack = new Pack(suitSet, rankSet, shuffle: false, decksCount); var expectedPackSize = suitSet.Count * rankSet.Count * decksCount; Assert.AreEqual(expectedPackSize, pack.Size); CollectionAssert.AreEqual(new[] { new Card(rankSet[0], suitSet[0]), new Card(rankSet[0], suitSet[0]), new Card(rankSet[1], suitSet[0]), new Card(rankSet[1], suitSet[0]), new Card(rankSet[0], suitSet[1]) }, pack.Take(5)); }