public async void RestoreFromChangeset_ReturnsNoContent() { var serviceMock = new Mock <IHistoricalCrudService <Guid, TestEntity> >(); serviceMock.Setup(_ => _.RestoreFromChangeset(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(_entity); var controller = new HistoricalCrudControllerBase <Guid, TestEntity>(null, serviceMock.Object); var actionResult = await controller.RestoreFromChangeset(_entity.Id, new Guid()); Assert.IsType <NoContentResult>(actionResult.Result); serviceMock.Verify(_ => _.RestoreFromChangeset(It.IsAny <Guid>(), It.IsAny <Guid>()), Times.Once); }
public async void RestoreFromChangeset_ReturnsBadRequest_For_UnmanageableException() { var serviceMock = new Mock <IHistoricalCrudService <Guid, TestEntity> >(); serviceMock.Setup(_ => _.RestoreFromChangeset(It.IsAny <Guid>(), It.IsAny <Guid>())).ThrowsAsync(new Exception()); var controller = new HistoricalCrudControllerBase <Guid, TestEntity>(null, serviceMock.Object); var actionResult = await controller.RestoreFromChangeset(_entity.Id, new Guid()); Assert.IsType <BadRequestObjectResult>(actionResult.Result); serviceMock.Verify(_ => _.RestoreFromChangeset(It.IsAny <Guid>(), It.IsAny <Guid>()), Times.Once); }