コード例 #1
0
        public void Restore_ThrowsEntityNotFoundException()
        {
            var serviceMock = new Mock <IHistoricalCrudService <TestEntity> >();

            serviceMock.Setup(_ => _.Restore(It.IsAny <Guid>())).Throws <EntityNotFoundException>();
            var controller = new HistoricalCrudController <TestEntity>(serviceMock.Object);

            var result = controller.Restore(_entity.Id);

            Assert.IsType <NotFoundResult>(result);
            serviceMock.Verify(_ => _.Restore(It.IsAny <Guid>()), Times.Once);
        }
コード例 #2
0
        public void Restore_ReturnsOk()
        {
            var serviceMock = new Mock <IHistoricalCrudService <TestEntity> >();

            serviceMock.Setup(_ => _.Restore(It.IsAny <Guid>())).Returns(_entity);
            var controller = new HistoricalCrudController <TestEntity>(serviceMock.Object);

            var result = controller.Restore(_entity.Id);

            Assert.IsType <OkObjectResult>(result);
            serviceMock.Verify(_ => _.Restore(It.IsAny <Guid>()), Times.Once);
        }