public void Delete_EnsureThatMethodIsCalled() { Mock <ISource> source = new Mock <ISource>(); var provider = new EmployeeProvider(source.Object); provider.Delete(5); source.Verify(s => s.Delete(5), Times.Once); }
public void Delete_EnsureThatMethodIsCalled() { ISource source = Substitute.For <ISource>(); var provider = new EmployeeProvider(source); provider.Delete(5); source.Received(1).Delete(5); }
void IBasicCommand.Delete() { gvwMaster.Rows.Cast <GridViewRow>().Where(gridViewRow => (gridViewRow.Cells[gridViewRow.Cells.Count - 1].Controls[1] as CheckBox).Checked).ForEach( gridViewRow => { string userName = gridViewRow.Cells[0].Text; try { if (userName.Equals("admin") || userName.Equals(UserManagement.GetCurrentUserName())) { throw new Exception(String.Format("User {0} cannot be deleted.", userName)); } UserManagement.DeleteUser(userName); employeeProvider.Delete(userName); } catch (Exception ex) { lblStatus.Text = String.Format("Cannot delete user <strong>{0}</strong>: {1}", userName, ex.Message); } }); ((IBasicCommand)this).Refresh(); }