public void IsLastDraw_ChecksIfItDeterminesLastDraw_Determines()
        {
            CardDTO card1 = new CardDTO(SymbolsDTO.DIAMONDS, 9);
            CardDTO card2 = new CardDTO(SymbolsDTO.HEARTS, 2);

            ActiveCardDTO activeDTO = new ActiveCardDTO(card1, card2);

            Assert.IsFalse(activeDTO.IsLastDraw());

            activeDTO.HumanCard = null;

            Assert.IsTrue(activeDTO.IsLastDraw());

            activeDTO.HumanCard = new CardDTO(SymbolsDTO.HEARTS, 5);

            Assert.IsFalse(activeDTO.IsLastDraw());

            activeDTO.ComputerCard = null;

            Assert.IsTrue(activeDTO.IsLastDraw());

            activeDTO.ComputerCard = new CardDTO(SymbolsDTO.DIAMONDS, 10);

            Assert.IsFalse(activeDTO.IsLastDraw());

            activeDTO.HumanCard = null;
            activeDTO.ComputerCard = null;

            Assert.IsTrue(activeDTO.IsLastDraw());
        }
        public ActiveCardDTO GetActiveCard()
        {
            ActiveCardDTO activeCard = new ActiveCardDTO();

            User user = GetUserFromContext();

            if(user.DeckCards.Count == 0)
            {
                activeCard.IsHumanWinner = false;
            }
            else if(user.DeckCards.Count == 52)
            {
                activeCard.IsHumanWinner = true;
            }
            else
            {
                IList<Card> missingCards = Deck.GetMissingCards(user.DeckCards);

                Random random = new Random();

                Card computerCard = missingCards[random.Next(missingCards.Count)];
                Card humanCard = user.DeckCards[0];
                activeCard.IsHumanWinner = Deck.IsCardGreater(humanCard, computerCard);

                if (activeCard.IsHumanWinner)
                {
                    user.DeckCards.Add(humanCard);
                    user.DeckCards.RemoveAt(0);
                    user.DeckCards.Add(computerCard);
                }
                else
                {
                    user.DeckCards.RemoveAt(0);
                }

                UserManager.UpdateUser(user);

                activeCard.ComputerCard = CardToDTOTransformer.GetCardDTO(computerCard);
                activeCard.HumanCard = CardToDTOTransformer.GetCardDTO(humanCard);
            }

            return activeCard;
        }
        public void SerializeAndDeserialize_ChecksIfObjectStateIsSavedCorrectly_Saved()
        {
            CardDTO card1 = new CardDTO(SymbolsDTO.DIAMONDS, 12);
            CardDTO card2 = new CardDTO(SymbolsDTO.HEARTS, 10);

            ActiveCardDTO activeDTO = new ActiveCardDTO(card1, card2);

            XmlSerializer SerializerObj = new XmlSerializer(typeof(ActiveCardDTO));

            TextWriter WriteFileStream = new StreamWriter("_activeCardDTO.xml");
            SerializerObj.Serialize(WriteFileStream, activeDTO);
            WriteFileStream.Close();

            FileStream ReadFileStream = new FileStream("_activeCardDTO.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
            ActiveCardDTO gotCard = (ActiveCardDTO)SerializerObj.Deserialize(ReadFileStream);
            ReadFileStream.Close();

            Assert.AreEqual(activeDTO.ComputerCard.Number, gotCard.ComputerCard.Number);
            Assert.AreEqual(activeDTO.ComputerCard.Symbol, gotCard.ComputerCard.Symbol);
            Assert.AreEqual(activeDTO.HumanCard.Number, gotCard.HumanCard.Number);
            Assert.AreEqual(activeDTO.HumanCard.Symbol, gotCard.HumanCard.Symbol);
        }