public IHttpActionResult Delete(Guid id) { bool result = _customersManager.Delete(id); if (result) { return(Ok()); } return(NotFound()); }
public async Task <IActionResult> Delete(long id) { try { await _customersManager.Delete(id); return(Json(new { Result = true })); } catch (Exception ex) { return(Json(new { Result = false, Message = ex.Message })); } }
[TestCase(false)] // passing customer id public void Delete_WhenCalled_ReturnsBoolean(bool isEmptyGuid) { //Arrange _unitOfWork.Setup(x => x.RepositoryFor <Entities.Customer>().Delete(Guid.NewGuid())).Returns(!isEmptyGuid); //Act bool func() => _customersManager.Delete(isEmptyGuid ? Guid.Empty : Guid.NewGuid()); //Assert if (isEmptyGuid) { Assert.That(() => func(), Throws.TypeOf <ArgumentNullException>()); } else { Assert.IsFalse(func()); } }