public async void Restore_ThrowsEntityNotFoundException() { var serviceMock = new Mock <IHistoricalCrudService <TestEntity> >(); serviceMock.Setup(_ => _.RestoreAsync(It.IsAny <Guid>())).ThrowsAsync(new EntityNotFoundException()); var controller = new HistoricalCrudController <Guid, TestEntity>(null, serviceMock.Object); var result = await controller.RestoreFromDeletedEntity(_entity.Id); Assert.IsType <NotFoundResult>(result); serviceMock.Verify(_ => _.RestoreAsync(It.IsAny <Guid>()), Times.Once); }
public async void RestoreAsync_ReturnsOk() { var serviceMock = new Mock <IHistoricalCrudService <TestEntity> >(); serviceMock.Setup(_ => _.RestoreAsync(It.IsAny <Guid>())).ReturnsAsync(_entity); var controller = new HistoricalCrudController <Guid, TestEntity>(null, serviceMock.Object); var result = await controller.RestoreFromDeletedEntity(_entity.Id); Assert.IsType <OkObjectResult>(result); serviceMock.Verify(_ => _.RestoreAsync(It.IsAny <Guid>()), Times.Once); }