public async void GetHistory_ThrowsEntityNotFoundException() { var serviceMock = new Mock <IHistoricalCrudService <TestEntity> >(); serviceMock.Setup(_ => _.GetHistoryAsync(It.IsAny <Guid>())).ThrowsAsync(new EntityNotFoundException()); var controller = new HistoricalCrudAsyncController <TestEntity>(serviceMock.Object); var result = await controller.GetHistory(_entity.Id); Assert.IsType <NotFoundResult>(result); serviceMock.Verify(_ => _.GetHistoryAsync(It.IsAny <Guid>()), Times.Once); }
public async void GetHistory_ReturnsOk() { var serviceMock = new Mock <IHistoricalCrudService <TestEntity> >(); serviceMock.Setup(_ => _.GetHistoryAsync(It.IsAny <Guid>())).ReturnsAsync(_events); var controller = new HistoricalCrudAsyncController <TestEntity>(serviceMock.Object); var result = await controller.GetHistory(_entity.Id); Assert.IsType <OkObjectResult>(result); serviceMock.Verify(_ => _.GetHistoryAsync(It.IsAny <Guid>()), Times.Once); }