Beispiel #1
0
        public async void Copy_ReturnsOk()
        {
            var serviceMock = new Mock <IHistoricalCrudService <Guid, TestEntity> >();

            serviceMock.Setup(_ => _.CopyAsync(It.IsAny <Guid>())).ReturnsAsync(_entity);
            var controller = new HistoricalCrudControllerBase <Guid, TestEntity>(null, serviceMock.Object);

            var actionResult = await controller.Copy(_entity.Id);

            Assert.IsType <CreatedAtActionResult>(actionResult.Result);
            serviceMock.Verify(_ => _.CopyAsync(It.IsAny <Guid>()), Times.Once);
        }
Beispiel #2
0
        public async void Copy_ReturnsNotFound()
        {
            var serviceMock = new Mock <IHistoricalCrudService <Guid, TestEntity> >();

            serviceMock.Setup(_ => _.CopyAsync(It.IsAny <Guid>())).ThrowsAsync(new EntityNotFoundException());
            var controller = new HistoricalCrudControllerBase <Guid, TestEntity>(null, serviceMock.Object);

            var actionResult = await controller.Copy(_entity.Id);

            Assert.IsType <NotFoundResult>(actionResult.Result);
            serviceMock.Verify(_ => _.CopyAsync(It.IsAny <Guid>()), Times.Once);
        }