public void InsertTest() { //Arrange gameTableDB = new GameTableDB(); bool found = false; var table = new GameTableModel("TestTable"); table.DeckId = 2; //Act gameTableDB.Insert(table); List <GameTableModel> gameTables = gameTableDB.GetAll().ToList(); for (int i = 0; i < gameTables.Count && !found; i++) { if (gameTables[i].TableName == table.TableName) { table.Id = gameTables[i].Id; } } var tableT = gameTableDB.GetById(table.Id); //Assert Assert.AreEqual(table.TableName, tableT.TableName); //Cleanup gameTableDB.Delete(table); }
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 void StartGameTest() { //Arrange GameController gameController = new GameController(); IGameDBIF gameDB = new GameDB(); IDeckDBIF deckDb = new DeckDB(); ICGUserDBIF userDB = new CGUserDB(); IGameTableDBIF gameTableDB = new GameTableDB(); List <GameModel> games = (List <GameModel>)gameDB.GetAll(); List <CGUser> users = CGUserConverter.ConvertFromListOfCGUserModelToListOfCGUser((List <CGUserModel>)userDB.GetAll()); GameTable gameTable = new GameTable { Deck = DeckConverter.ConvertFromDeckModelToDeck(deckDb.GetById(2)), seats = 4, TableName = "TestTable", }; if (users.Count > 4) { for (int i = 0; i < 4; i++) { gameTable.Users.Add(users[i]); } } gameTableDB.Insert(GameTableConverter.ConvertFromGameTableToGameTableModel(gameTable)); gameTable = GameTableConverter.ConvertFromGameTableModelToGameTable(gameTableDB.GetGameTableByTableName("TestTable")); //Act gameController.StartGame(gameTable); List <GameModel> games2 = (List <GameModel>)gameDB.GetAll(); //Assert Assert.AreNotEqual(games.Count, games2.Count); //Cleanup gameDB.Delete(gameDB.GetByTableId(gameTable.Id)); gameTableDB.Delete(GameTableConverter.ConvertFromGameTableToGameTableModel(gameTable)); }