public void JobPositionWithInvalidId_WhenDeleted_ThrowsExeption() { var service = new JobPositionService(context); var ex = Assert.Throws <ArgumentException>(() => service.DeleteJobPosition(1)); Assert.That(ex.Message, Is.EqualTo("Invalid job position id. (Parameter 'id')")); }
public void JobPosition_CanBeDeleted() { context.JobPositions.Add(new JobPosition { Name = "JobPosition" }); context.SaveChanges(); var service = new JobPositionService(context); service.DeleteJobPosition(1); Assert.AreEqual(0, context.JobPositions.Count()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } try { // _context.Certificates.Remove(Certificate); _jobPositionService.DeleteJobPosition(JobPosition); //await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (DbUpdateException ex) { _logger.LogError(ex, ErrorMessage); return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }