public void Create_Should_Call_UnitOfWork_And_Repository()
        {
            // Act
            _ = _productsProvider.Create(new ProductEntity());

            // Assert
            _unitOfWorkMock.Verify(x => x.Repository <ProductEntity>(), Times.Once());
            _repositoryMock.Verify(x => x.Add(It.IsAny <ProductEntity>()), Times.Once());
            _unitOfWorkMock.Verify(x => x.SaveChanges(), Times.Once());
        }
Exemplo n.º 2
0
        public ActionResult <Product> Create([FromBody] Product product)
        {
            try
            {
                return(_provider.Create(product));
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception during providing products, maybe DB is not fully initialized yet? " +
                                  $"Try again in a few minutes and if it doesn't help, check your docker-compose configuration.\n{e}");

                return(null);
            }
        }