Example #1
0
 public void drawTest()
 {
     Deck target = new Deck(); // TODO: Initialize to an appropriate value
     Card expected = new DefenceCard(5); // TODO: Initialize to an appropriate value
     Card actual;
     actual = target.draw();
     Assert.AreEqual(expected.getValue(), actual.getValue(),"The Value is not equal.");
 }
Example #2
0
 public void shuffleTest()
 {
     Deck target = new Deck(); // TODO: Initialize to an appropriate value
     target.shuffle();
     Card expected = new DefenceCard(5); // TODO: Initialize to an appropriate value
     Card actual;
     actual = target.draw();
     //NOTE! THIS IS AN UNPREDICTABLE TEST. I'm using it as an initial check for shuffling,
     //but there's a good chance it will fail just because of the luck of the draw.
     Assert.AreEqual(expected.getValue(), actual.getValue(), "The deck has not been shuffled.");
 }
 public static Card RecieveCard(Socket handler)
 {
     UI.Write("Please wait for your opponent to play a card.");
     Card recievedCard;
     string cardInfo = null;
     byte[] bytes;
     int bytesRec;
     while (true)
     {
         bytes = new byte[1024];
         bytesRec = handler.Receive(bytes);
         cardInfo += Encoding.ASCII.GetString(bytes, 0, bytesRec);
         if (cardInfo.IndexOf("<EOF>") > -1)
         {
             break;
         }
     }
     //Everything between # and <
     int value = Convert.ToInt32((cardInfo.Substring(cardInfo.IndexOf("#") + 1, cardInfo.IndexOf("<") - cardInfo.IndexOf("#") - 1)));
     switch (cardInfo[0])
     {
         case ('0'):
             recievedCard = new AttackCard(value);
             break;
         case ('1'):
             recievedCard = new DefenceCard(value);
             break;
         case ('2'):
             recievedCard = new HealCard(value);
             break;
         default:
             recievedCard = new AttackCard(0);
             break;
     }
     return recievedCard;
 }