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