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

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

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

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

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

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

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