public void GetUserByTableIdTest() { //Arrange cgUserDB = new CGUserDB(); GameTableDB gameTableDB = new GameTableDB(); var table = new GameTableModel("TestTable"); table.DeckId = 2; table.seats = 4; //Act gameTableDB.Insert(table); table = gameTableDB.GetGameTableByTableName("TestTable"); GameTable gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(table); gameTable.Users.Add(CGUserConverter.convertFromCGUserModelToCGUser(cgUserDB.GetById("Test"))); CGUserModel testUser = cgUserDB.GetById("Test"); cgUserDB.UpdateUserTableId(testUser, table.Id); List <CGUserModel> foundUser = cgUserDB.GetUserByTableId(table.Id); Assert.AreEqual(testUser.UserName, foundUser[0].UserName); gameTableDB.Delete(table); }
public static GameTable ConvertFromGameTableModelToGameTable(GameTableModel tableModel) { CGUserDB cGUserDB = new CGUserDB(); DeckDB deckDB = new DeckDB(); GameTable gameTable = new GameTable() { Id = tableModel.Id, seats = tableModel.seats, TableName = tableModel.TableName, Users = CGUserConverter.ConvertFromListOfCGUserModelToListOfCGUser(cGUserDB.GetUserByTableId(tableModel.Id)), Deck = DeckConverter.ConvertFromDeckModelToDeck(deckDB.GetById(tableModel.DeckId)) }; return(gameTable); }