public async void Copy_ReturnsNotFound() { var serviceMock = new Mock <ICrudService <Guid, TestEntity> >(); serviceMock.Setup(_ => _.CopyAsync(It.IsAny <Guid>())).ThrowsAsync(new EntityNotFoundException()); var controller = new CrudControllerBase <Guid, TestEntity>(serviceMock.Object); var actionResult = await controller.Copy(_entity.Id); Assert.IsType <NotFoundResult>(actionResult.Result); serviceMock.Verify(_ => _.CopyAsync(It.IsAny <Guid>()), Times.Once); }
public async void Copy_ReturnsOk() { var serviceMock = new Mock <ICrudService <Guid, TestEntity> >(); serviceMock.Setup(_ => _.CopyAsync(It.IsAny <Guid>())).ReturnsAsync(_entity); var controller = new CrudControllerBase <Guid, TestEntity>(serviceMock.Object); var actionResult = await controller.Copy(_entity.Id); Assert.IsType <CreatedAtActionResult>(actionResult.Result); serviceMock.Verify(_ => _.CopyAsync(It.IsAny <Guid>()), Times.Once); }