public async void HeadById_ReturnsAsyncNotFound() { var serviceMock = new Mock <ICrudService <Guid, TestEntity> >(); serviceMock.Setup(_ => _.GetByIdAsync(It.IsAny <Guid>())).Throws(new EntityNotFoundException()); var controller = new CrudControllerBase <Guid, TestEntity>(serviceMock.Object); var actionResult = await controller.HeadById(Guid.NewGuid()); Assert.IsType <NotFoundResult>(actionResult); serviceMock.Verify(_ => _.GetByIdAsync(It.IsAny <Guid>()), Times.Once); }
public async void HeadById_ReturnsAsyncNoContent() { var id = _entities[0].Id; var serviceMock = new Mock <ICrudService <Guid, TestEntity> >(); serviceMock.Setup(_ => _.GetByIdAsync(id)).ReturnsAsync(_entities[0]); var controller = new CrudControllerBase <Guid, TestEntity>(serviceMock.Object); var actionResult = await controller.HeadById(id); Assert.IsType <NoContentResult>(actionResult); serviceMock.Verify(_ => _.GetByIdAsync(It.IsAny <Guid>()), Times.Once); }