public void TooManyCards()
        {
            JsonResult         result    = testController.GeneratedCardHands(6, 10) as JsonResult;
            CardHandsViewModel viewModel = shucker.Shuck <CardHandsViewModel>(result);

            Assert.IsNotNull(viewModel, "Generated view model was null.");

            Assert.IsNull(viewModel.RequestedHands, "Hands generated when they shouldn't have been.");
        }
        public void BasicHandsRetrieval()
        {
            JsonResult         result    = testController.GeneratedCardHands(4, 10) as JsonResult;
            CardHandsViewModel viewModel = shucker.Shuck <CardHandsViewModel>(result);

            Assert.IsNotNull(viewModel, "Generated view model was null.");

            List <List <Card> > dealtHands = viewModel.RequestedHands;

            Assert.IsNotNull(dealtHands, "Hands not dealt correctly.");
            Assert.AreEqual(4, dealtHands.Count, "Incorrect number of hands generated.");
            Assert.AreEqual(10, dealtHands[2].Count, "Incorrect number of cards in dealth hand.");
        }
        /// <summary>
        ///     Used to retrieve randomly dealt hands of cards.
        /// </summary>
        /// <param name="HandCount">The number of hands to deal.</param>
        /// <param name="CardsPerHand">The number of cards per hand.</param>
        /// <returns>
        ///     The set of requested card hands. If either the number of hands
        ///     requested or the number of cards per hand is not greater than 0,
        ///     this list will be empty.
        ///
        ///     If the total number of requested cards is more than is in a started deck,
        ///     the list will be empty.
        ///
        ///     The list is wrapped in an object which will cause the MVC framework to
        ///     generate the JSON representation of the list of hands.
        ///
        ///     GET: /CardHands?HandCount={HandCount}&CardsPerHand={CardsPerHand}
        /// </returns>
        public ActionResult GeneratedCardHands(int HandCount, int CardsPerHand)
        {
            CardHandsViewModel viewModel = viewModelFactory();

            viewModel.RequestedHands = new List <List <Card> >();

            if (HandCount > 0 && CardsPerHand > 0)
            {
                CardDeck deck = cardDeckFactory();
                viewModel.RequestedHands = deck.Deal(HandCount, CardsPerHand);
            }

            // This must be manually allowed since retrieving JSON via GET requests can lead
            // to cross-site scripting arrays. This is only a danger if raw arraws are being
            // returned at the root level of the request which is not the case here.
            return(Json(viewModel, JsonRequestBehavior.AllowGet));
        }