public void DeleteCallsDeleteOp() { var obj = new { a = 1 }; Ops.Setup(c => c.DeleteRow("conn", "tbl", LoggingService, "14")) .Returns(obj); var controller = new TablesController(Ops.Object, LoggingService, _queryStringService); dynamic results = controller.Delete("conn", "tbl", "14"); Assert.AreEqual(1, results.a); }
private async void BtnDelete_Click(object sender, EventArgs e) { if (nameOfFormOpen.Equals("VenuesGUI") && VenuesGUI.Instance.idFromTable != -1) { try { VenuesController vCtrl = new VenuesController(); VenuesGUI.Instance.UseWaitCursor = true; await vCtrl.Delete(VenuesGUI.Instance.idFromTable); VenuesGUI.Instance.UseWaitCursor = false; } catch (Exception) { MessageBox.Show("Error...occured"); VenuesGUI.Instance.UseWaitCursor = false; } } else if (nameOfFormOpen.Equals("TablesGUI") && TablesGUI.Instance.idFromTable != -1) { try { TablesController tCtrl = new TablesController(); TablesGUI.Instance.UseWaitCursor = true; await tCtrl.Delete(TablesGUI.Instance.idFromTable); TablesGUI.Instance.UseWaitCursor = false; } catch (Exception) { MessageBox.Show("Error...occured"); TablesGUI.Instance.UseWaitCursor = false; } } else if (nameOfFormOpen.Equals("TablePackagesGUI") && TablePackagesGUI.Instance.idFromTable != -1) { try { TablePackagesController tpCtrl = new TablePackagesController(); TablePackagesGUI.Instance.UseWaitCursor = true; await tpCtrl.Delete(TablePackagesGUI.Instance.idFromTable); TablePackagesGUI.Instance.UseWaitCursor = false; } catch (Exception) { MessageBox.Show("Error...occured"); TablePackagesGUI.Instance.UseWaitCursor = false; } } else if (nameOfFormOpen.Equals("EmployeesGUI") && EmployeesGUI.Instance.IdFromTable != -1) { try { EmployeesController eCtrl = new EmployeesController(); EmployeesGUI.Instance.UseWaitCursor = true; await eCtrl.Delete(EmployeesGUI.Instance.IdFromTable); EmployeesGUI.Instance.UseWaitCursor = false; } catch (Exception) { MessageBox.Show("Error...occured"); EmployeesGUI.Instance.UseWaitCursor = false; } } else if (nameOfFormOpen.Equals("ReservationsGUI") && ReservationsGUI.Instance.IdFromTable != -1) { try { ReservationsController rCtrl = new ReservationsController(); ReservationsGUI.Instance.UseWaitCursor = true; await rCtrl.Delete(ReservationsGUI.Instance.IdFromTable); ReservationsGUI.Instance.UseWaitCursor = false; } catch (Exception) { MessageBox.Show("Error...occured"); EmployeesGUI.Instance.UseWaitCursor = false; } } else { MessageBox.Show("Please select a " + newTitle + " from the list"); } }