예제 #1
0
        public void Serialize_ListCards_And_Deserialize()
        {
            var card = new Card
            {
                Color = Card.Colors.Black,
                Suite = Card.Suites.Clubs,
                State = Card.States.Available,
                Value = 2
            };
            var cards = new List<Card> {card};

            var serialized = Util.Serialize(cards);
            var deserialized = Util.DeSerialize<List<Card>>(serialized);

            Assert.IsNotNull(deserialized);
            Assert.AreEqual(1, deserialized.Count());
            Assert.AreEqual(card.Color, deserialized[0].Color);
            Assert.AreEqual(card.Suite, deserialized[0].Suite);
            Assert.AreEqual(card.State, deserialized[0].State);
            Assert.AreEqual(card.Value, deserialized[0].Value);
        }
예제 #2
0
 private void TestDeckCardsValues(Deck deck, Card.Suites suite)
 {
     for (var v = 1; v < 14; v++)
     {
         Assert.IsTrue(deck.Cards.Any(x => x.Suite == suite && x.Value == v), string.Format("Card value {0}, suite: {1} does not exist.", v, suite));
     }
 }
예제 #3
0
        public void ToPokerTableEntity_Should_Return_PokerTableEntity_With_Valid_Values()
        {
            var table = new Table("Test", "TestPassword");
            var card = new Card
            {
                Color = Card.Colors.Black,
                State = Card.States.Available,
                Suite = Card.Suites.Clubs,
                Value = 2
            };
            table.Deck.Cards.Add(card);
            table.Burn.Add(card);
            table.PublicCards.Add(card);

            var result = table.ToPokerTableEntity();

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(PokerTableEntity));
            Assert.AreEqual(table.Id.ToString(), result.PartitionKey);
            Assert.AreEqual(PokerTableEntity.Prefix, result.RowKey);
            Assert.AreEqual(table.Name, result.Name);
            Assert.AreEqual(table.Password, result.Password);
            Assert.IsTrue(!string.IsNullOrEmpty(result.Deck));
            Assert.IsTrue(!string.IsNullOrEmpty(result.BurnCards));
            Assert.IsTrue(!string.IsNullOrEmpty(result.PublicCards));
        }
예제 #4
0
        public void ToTableModel_Should_Return_Table_With_Valid_Values()
        {
            var table = new Table("Test", "TestPassword");
            var card = new Card
            {
                Color = Card.Colors.Black,
                State = Card.States.Available,
                Suite = Card.Suites.Clubs,
                Value = 2
            };
            table.Deck.Cards.Add(card);
            table.Burn.Add(card);
            table.PublicCards.Add(card);

            var tableEntity = table.ToPokerTableEntity();
            var tableModel = tableEntity.ToTableModel();

            Assert.IsNotNull(tableModel);
            Assert.IsInstanceOfType(tableModel, typeof(Table));
            Assert.AreEqual(table.Id, tableModel.Id);
            Assert.AreEqual(table.Name, tableModel.Name);
            Assert.AreEqual(table.Password, tableModel.Password);

            Assert.AreEqual(table.Deck.Cards[0].Color, tableModel.Deck.Cards[0].Color);
            Assert.AreEqual(table.Deck.Cards[0].State, tableModel.Deck.Cards[0].State);
            Assert.AreEqual(table.Deck.Cards[0].Suite, tableModel.Deck.Cards[0].Suite);
            Assert.AreEqual(table.Deck.Cards[0].Value, tableModel.Deck.Cards[0].Value);

            Assert.AreEqual(table.Burn[0].Color, tableModel.Burn[0].Color);
            Assert.AreEqual(table.Burn[0].State, tableModel.Burn[0].State);
            Assert.AreEqual(table.Burn[0].Suite, tableModel.Burn[0].Suite);
            Assert.AreEqual(table.Burn[0].Value, tableModel.Burn[0].Value);

            Assert.AreEqual(table.PublicCards[0].Color, tableModel.PublicCards[0].Color);
            Assert.AreEqual(table.PublicCards[0].State, tableModel.PublicCards[0].State);
            Assert.AreEqual(table.PublicCards[0].Suite, tableModel.PublicCards[0].Suite);
            Assert.AreEqual(table.PublicCards[0].Value, tableModel.PublicCards[0].Value);
        }
예제 #5
0
 private void TestCardValue(Card card, string expectedPrefix)
 {
     Assert.IsTrue(card.Name().StartsWith(expectedPrefix));
 }
예제 #6
0
 private void TestCardSuit(Card card, string expectedSuffix)
 {
     Assert.IsTrue(card.Name().EndsWith(expectedSuffix));
 }
예제 #7
0
 public void IfCardSuiteIsNotDefined_Should_Throw_ArgumentException()
 {
     var card = new Card();
     var result = card.Name();
 }
예제 #8
0
 public void CardValueLessThen1_Name_Should_Throw_ArgumentException()
 {
     var card = new Card() { Suite = Card.Suites.Spades, Value = 0 };
     var result = card.Name();
 }