public void DeleteTest() { //Arrange GameTableController gameTableController = new GameTableController(); CGUserModel userModel = new CGUserModel { Id = "Test", Email = "*****@*****.**", UserName = "******" }; GameTableModel tableModel = null; gameTableController.CreateGameTable(userModel, "TestTable"); List <GameTableModel> tables = gameTableController.GetAll(); foreach (var table in tables) { if (table.TableName == "TestTable") { tableModel = table; } } bool res = false; //Act res = gameTableController.Delete(tableModel.Id); //Assert Assert.IsTrue(res); }
private void buttonDelete_Click(object sender, EventArgs e) { try { string id = GameTableIdTextBox.Text; if (!string.IsNullOrEmpty(id)) { int tableId = Int32.Parse(id); bool delete = gameTableController.Delete(tableId); if (delete) { labelDelete.ForeColor = Color.Green; labelDelete.Text = "Table is deleted " + "Table ID: " + GameTableIdTextBox.Text + " Table Name: " + GameTableNameTextBox.Text; UpdateGameTableListBox(); } } else { labelDelete.ForeColor = Color.Red; labelDelete.Text = "Input valid tableId !"; } } catch (Exception) { MessageBox.Show("Bordet er i brug", "Bordet kan ikke slettes"); } }