public void OneDeck_InitializeThenShuffle_NoDuplicates()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     Assert.AreEqual(testdeck.AreCardsUnique(), true);
 }
        public void OneDeck_DeckContains52Cards_IsTrue()
        {
            Deck testdeck = new Deck();
            testdeck.InitializeFullDeck();

            Assert.AreEqual(testdeck.Cards.Count == 52, true);
        }
 public void OneDeck_DeckShuffled_WillNotBeSorted()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     Assert.AreEqual(testdeck.IsSorted(), false);
 }
        public void OneDeck_CreateTwoCardsTheSameSuitAndValueOnFullDeck_DeckCardsWillNotBeUnique()
        {
            Deck testdeck = new Deck();
            testdeck.InitializeFullDeck();
            testdeck.Cards.Add(new Card { cardsuit = 1, cardvalue = 3 });

            Assert.AreEqual(testdeck.Cards.Count == 53, true);
            Assert.AreEqual(testdeck.AreCardsUnique(), false);
        }
        public void OneDeck_RemoveACard_CardsWillRemainSorted()
        {
            Deck testdeck = new Deck();
            testdeck.InitializeFullDeck();

            Random rnd = new Random();
            var numOfCards = testdeck.Cards.Count;

            testdeck.Cards.RemoveAt(rnd.Next(numOfCards));
            Assert.AreEqual(testdeck.AreCardsUnique(), true);
            Assert.AreEqual(testdeck.IsSorted(), true);
        }
 public void OneDeck_IsItSortedWhenInitialized_WillBeSorted()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     Assert.AreEqual(testdeck.IsSorted(), true);
 }
        public void TwoDeck_ShuffleOneSortOther_BothHaveKeptState()
        {
            Deck testdeck = new Deck();
            Deck testdeck2 = new Deck();

            testdeck.InitializeFullDeck();
            testdeck2.InitializeFullDeck();

            testdeck.Shuffle();
            testdeck.Sort();
            testdeck2.Shuffle();

            Assert.AreEqual(testdeck.IsSorted(), true);
            Assert.AreEqual(testdeck2.IsSorted(), false);
        }
 public void OneDeck_ShuffledThenSorted_WillBeSorted()
 {
     Deck testdeck = new Deck();
     testdeck.InitializeFullDeck();
     testdeck.Shuffle();
     testdeck.Sort();
     Assert.AreEqual(testdeck.IsSorted(), true);
 }
Beispiel #9
0
        static void Main(string[] args)
        {
            Deck deck1 = new Deck();
            int  k;

            for (int i = 0; i < 2; i++)
            {
                for (int j = 1; j < (6 + 1); j++)
                {
                    deck1.Cards.Add(new Card {
                        cardsuit = i, cardvalue = j
                    });
                }
            }
            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the incomplete Deck is Sorted\n");
            }

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }
            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");


            deck1.Shuffle();
            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\nLet's Initialize a full deck\n");
            deck1.InitializeFullDeck();

            bool tmp = deck1.AreCardsUnique();

            if (tmp && deck1.Cards.Count() == 52)
            {
                Console.WriteLine("We have 52 card and no duplicates - we have an official set!\n\n");
            }

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");

            deck1.Shuffle();

            if (!deck1.IsSorted())
            {
                Console.WriteLine("\nThe Deck is not Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
            {
                Console.WriteLine("({0}) drew a {1}", k++, Card.GetCardName(card));
            }

            Console.WriteLine("\n\nLet's Sort The Deck!\n\n");

            deck1.Sort();

            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the Deck is Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
            {
                Console.WriteLine("({0}) drew a(n) {1}", k++, Card.GetCardName(card));
            }

            Console.ReadLine();
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            Deck deck1 = new Deck();
            int k;
            for (int i = 0; i < 2; i++)
            {
                for (int j = 1; j< (6 + 1); j++)
                {
                    deck1.Cards.Add(new Card { cardsuit = i, cardvalue = j });
                }
            }
            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the incomplete Deck is Sorted\n");
            }

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }
            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");

            deck1.Shuffle();
            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\nLet's Initialize a full deck\n");
            deck1.InitializeFullDeck();

            bool tmp = deck1.AreCardsUnique();
            if (tmp && deck1.Cards.Count() == 52)
                Console.WriteLine("We have 52 card and no duplicates - we have an official set!\n\n");

            for (Card tmpcard = deck1.DealCard(); tmpcard != null; tmpcard = deck1.DealCard())
            {
                Console.Write("drew: a(n)  {0}\n", Card.GetCardName(tmpcard));
            }

            Console.WriteLine("\n\nLet's Shuffle The Deck!\n\n");

            deck1.Shuffle();

            if (!deck1.IsSorted())
            {
                Console.WriteLine("\nThe Deck is not Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
                Console.WriteLine("({0}) drew a {1}", k++, Card.GetCardName(card));

            Console.WriteLine("\n\nLet's Sort The Deck!\n\n");

            deck1.Sort();

            if (deck1.IsSorted())
            {
                Console.WriteLine("\nYes the Deck is Sorted\n");
            }

            k = 1;

            foreach (var card in deck1.Cards)
                Console.WriteLine("({0}) drew a(n) {1}", k++, Card.GetCardName(card));

            Console.ReadLine();
        }