Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }