private void _view_OnDeleteClick(object sender, EventArgs e) { using (new WaitCursorHandler()) { if (_view.ListDataGrid != null && _view.ListDataGrid.SelectedItem != null && Messages.ConfirmDelete(_typeName)) { try { var model = _services.GetById(((PenjualanModel)_view.ListDataGrid.SelectedItem).id); _services.Delete(model); Messages.InfoDelete(_typeName); if (_listReturnPenjualans.Remove((PenjualanReturnModel)_view.ListDataGrid.SelectedItem)) { _bindingView.DataSource = _listReturnPenjualans; } } catch (DataAccessException ex) { Messages.Error(ex); } finally { if (_view.ListDataGrid.SelectedItem != null) { _view.ListDataGrid.SelectedItem = null; } } } } }
private void ShouldReturnSuccessForDelete() { var operationSecceded = false; var dataAccessJsonStr = string.Empty; var formattedJsonStr = string.Empty; try { var model = new PenjualanReturnModel() { id = 12, penjualan_id = 13 }; _services.Delete(model); operationSecceded = true; } catch (DataAccessException ex) { operationSecceded = ex.DataAccessStatusInfo.OperationSucceeded; dataAccessJsonStr = JsonConvert.SerializeObject(ex.DataAccessStatusInfo); formattedJsonStr = JToken.Parse(dataAccessJsonStr).ToString(); } try { Assert.True(operationSecceded); _testOutputHelper.WriteLine("Data berhasil dihapus."); } finally { _testOutputHelper.WriteLine(formattedJsonStr); } }