Ejemplo n.º 1
0
        public IHttpActionResult Delete(Guid id)
        {
            bool result = _customersManager.Delete(id);

            if (result)
            {
                return(Ok());
            }
            return(NotFound());
        }
Ejemplo n.º 2
0
        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 }));
            }
        }
Ejemplo n.º 3
0
        [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());
            }
        }