public async void Update_ReturnsAsyncModifiedEntity()
        {
            var serviceMock = new Mock <ICrudService <TestEntity> >();
            var controller  = new CrudAsyncController <TestEntity>(serviceMock.Object);

            var actionResult = await controller.Update(_entity.Id, _entity);

            Assert.IsType <OkObjectResult>(actionResult);
            serviceMock.Verify(_ => _.UpdateAsync(It.IsAny <Guid>(), It.IsAny <TestEntity>()), Times.Once);
        }
        public async void GetById_ReturnsAsyncNotFound()
        {
            var serviceMock = new Mock <ICrudService <TestEntity> >();

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

            var actionResult = await controller.GetById(Guid.NewGuid());

            Assert.IsType <NotFoundResult>(actionResult);
            serviceMock.Verify(_ => _.GetByIdAsync(It.IsAny <Guid>()), Times.Once);
        }
        public async void Delete_ReturnsAsyncNotFound()
        {
            var serviceMock = new Mock <ICrudService <TestEntity> >();

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

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

            Assert.IsType <NotFoundResult>(actionResult);
            serviceMock.Verify(_ => _.DeleteAsync(It.IsAny <Guid>()), Times.Once);
        }
        public async void GetAll_ReturnsAsyncOk()
        {
            var serviceMock = new Mock <ICrudService <TestEntity> >();

            serviceMock.Setup(_ => _.GetAllAsync()).ReturnsAsync(_entities);
            var controller = new CrudAsyncController <TestEntity>(serviceMock.Object);

            var actionResult = await controller.GetAll();

            var okResult = actionResult as OkObjectResult;
            var model    = okResult.Value as IEnumerable <TestEntity>;

            Assert.Equal(model.Count(), _entities.Count);
            serviceMock.Verify(_ => _.GetAllAsync(), Times.Once);
        }
        public async void GetById_ReturnsAsyncOk()
        {
            var id          = _entities[0].Id;
            var serviceMock = new Mock <ICrudService <TestEntity> >();

            serviceMock.Setup(_ => _.GetByIdAsync(id)).ReturnsAsync(_entities[0]);
            var controller = new CrudAsyncController <TestEntity>(serviceMock.Object);

            var actionResult = await controller.GetById(id);

            var okResult = actionResult as OkObjectResult;
            var model    = okResult.Value as TestEntity;

            Assert.Equal(model.Id, id);
            serviceMock.Verify(_ => _.GetByIdAsync(It.IsAny <Guid>()), Times.Once);
        }