private void _view_OnDeleteData(object sender, EventArgs e) { using (new WaitCursorHandler()) { if (_view.ListDataGrid != null && _view.ListDataGrid.SelectedItem != null && Messages.ConfirmDelete(_typeName)) { try { var model = _services.GetById(((TipeModel)_view.ListDataGrid.SelectedItem).id); _services.Delete(model); Messages.InfoDelete(_typeName); if (_listObjs.Remove((TipeModel)_view.ListDataGrid.SelectedItem)) { _bindingView.DataSource = _listObjs; } } catch (DataAccessException ex) { Messages.Error(ex); _view_OnRefreshData(null, null); } 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 TipeModel() { id = 10, }; _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); } }