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