Ejemplo n.º 1
0
        public async Task DeleteAsync_ThrowsException_WhenNotExists()
        {
            A.CallTo(() => _genresRepository.FindSingleAsync(A <Expression <Func <Genre, bool> > > ._))
            .Returns((Genre)null);

            Func <Task> action = async() => await _genreServices.DeleteAsync(Id);

            await action.Should().ThrowAsync <EntityNotFoundException <Genre> >()
            .WithMessage($"Entity Genre wasn't found. Id: {Id}");
        }
Ejemplo n.º 2
0
        //[HttpGet, Route({entityId}]
        public async Task <IActionResult> DeleteAsync(int entityId)
        {
            var deleteResult = await _service.DeleteAsync(entityId);

            if (!deleteResult)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Failed to delete entity."));
            }
            return(Ok());
        }