public void Test_Knuth_Shuffler_Uses_All_Elements_From_Given_Enumerable() { var knuthShuffler = new KnuthShuffler(); var initial = new byte[] { 0, 1, 2, 3, 3 }.ToList(); var shuffled = knuthShuffler.Shuffle(initial); Assert.Equal(initial.Count, shuffled.Count()); foreach (var elm in shuffled) { initial.Remove(elm); } Assert.Empty(initial); }
public void ShuffleDelegateStrategyTest() { // It is possible, but highly unlikely that the 1st five cards of a // shuffled deck would be the same as the first 5 cards in an unshuffled deck. CardDeck deck = new CardDeck(); string c1 = deck.Deal().Code; string c2 = deck.Deal().Code; string c3 = deck.Deal().Code; string c4 = deck.Deal().Code; string c5 = deck.Deal().Code; deck = new CardDeck(); IShuffler shuffler = new KnuthShuffler(); deck.Shuffle(shuffler.Shuffle); string a1 = deck.Deal().Code; string a2 = deck.Deal().Code; string a3 = deck.Deal().Code; string a4 = deck.Deal().Code; string a5 = deck.Deal().Code; Assert.IsFalse((c1 == a1) && (c2 == a2) && (c3 == a3) && (c4 == a4) && (c5 == a5)); }