internal static Table ToTableModel(this PokerTableEntity pokerTableEntity) { var table = new Table(pokerTableEntity.Name, pokerTableEntity.Password) { Id = Guid.Parse(pokerTableEntity.PartitionKey), Deck = Util.DeSerialize<Deck>(pokerTableEntity.Deck), Burn = Util.DeSerialize<List<Card>>(pokerTableEntity.BurnCards), PublicCards = Util.DeSerialize<List<Card>>(pokerTableEntity.PublicCards) }; return table; }
public void JoingTable_SameNameAsExistingPlayer_Returns_ExistingPlayersGuid() { var expectedPlayer = new Player("RoboCop"); var table = new Table("TableName", "TablePassword"); table.Players.Add(expectedPlayer); var someTableGuid = Guid.NewGuid(); this.repositoryMock.Setup(x => x.GetTableIdByTablePassword(It.IsAny<string>())).Returns(someTableGuid); this.repositoryMock.Setup(x => x.LoadTable(someTableGuid)).Returns(table); var playerGuid = this.engine.JoinTable("Some Password", expectedPlayer.Name); Assert.AreEqual(expectedPlayer.Id, playerGuid); }
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)); }
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); }
public void LoadTable(Guid tableId) { this.Table = this.repository.LoadTable(tableId); }
public void CreateNewTable(int numberOfSeats, string name) { this.Table = new Table(name, this.GetNewTablePassword()); this.AddManySeats(numberOfSeats); this.BuildDeck(); this.ShuffleDeck(); this.repository.SaveTable(this.Table); this.repository.DeleteOldTables(); }