public void Transaction_AddEntity()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _transactionScopeRepository.AddProduct(product);

            Assert.IsTrue(result);
        }
        public void Transaction_AddEntityWithFind()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddProduct(product);

            Product productResult = _productRepository.FindProductByProductName("Duvel Green");

            Assert.IsNotNull(productResult);
        }
        public void Transaction_AddEntityWithNavigationPath()
        {
            bool result = false;

            Supplier supplier = _supplierRepository.FindSupplierBySupplierID(1);

            Product product = new MockProduct()
                .CreateSingleProduct();

            product.Supplier = supplier;
            result = _productRepository.AddProduct(product);

            Assert.IsTrue(result);
        }
        public void Transaction_UpdateMultipleEntities()
        {
            bool result = false;

            List<Product> products = new MockProduct()
                .CreateMultipleProducts(5000);

            products.ForEach(x => x.ProductName = "Duvel Hop");

            result = _transactionScopeRepository.UpdateMultipleProducts(products);

            List<Product> resultProducts = _transactionScopeRepository.FindProductsByProductName("Duvel Hop");

            Assert.IsTrue(result);
        }
        public async Task Transaction_AddEntityAsync()
        {
            //var stubs = Stubs<Product>.Create(new int[]{ 1, 2});

            var result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            using (IAsyncProductRepository asyncRepo = new AsyncProductRepository())
            {
                result = await _productRepository.AddProduct(product);
            }

            Assert.IsTrue(result);
        }
        public void Transaction_DeleteEntity()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddOrUpdate<Product>(product);

            Product resultProduct = _productRepository.Find<Product>(x => x.ProductName == product.ProductName)
                .FirstOrDefault();

            result = _productRepository.Delete<Product>(resultProduct);

            Assert.IsTrue(result);
        }
        public void Transaction_UpdateEntity()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _transactionScopeRepository.AddProduct(product);

            Product resultProduct = _transactionScopeRepository.FindProductByProductName("Duvel Green");

            resultProduct.ProductName = "Duvel Red";
            result = _transactionScopeRepository.UpdateProduct(resultProduct);

            Assert.IsTrue(result);
        }
        public void Transaction_AddOrUpdateMultipleEntitiesWithCommit()
        {
            bool result = false;

            List<Product> products = new MockProduct()
                .CreateMultipleProducts(5000);

            products.ForEach(x => x.ProductName = "Duvel Hop");

            result = _productRepository.AddOrUpdateMultipleCommit<Product>(products);

            List<Product> resultProducts = _productRepository.Find<Product>(x => x.ProductName == "Duvel Hop")
                .ToList();

            Assert.IsTrue(result);
        }
        public void Transaction_UpdateEntity()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddProduct(product);

            Product resultProduct = _productRepository.Find<Product>(x => x.ProductName == "Duvel Green")
                .FirstOrDefault();

            resultProduct.ProductName = "Duvel Red";

            result = _productRepository.Update<Product>(resultProduct);

            Assert.IsTrue(result);
        }
        public void Transaction_UpdateNavigationEntityWithInclude()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddProduct(product);

            Product resultProduct = _productRepository.Find<Product>(x => x.ProductName == "Duvel Green",
                x => x.Supplier)
                .FirstOrDefault();

            resultProduct.Supplier.CompanyName = "Exoctic liquids";

            result = _productRepository.Update<Product>(resultProduct);

            Assert.IsTrue(result);
        }
        public void Transaction_UpdateNavigationEntity()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            Supplier supplier = _productRepository.Find<Supplier>(x => x.SupplierID == 1)
                .FirstOrDefault();

            supplier.CompanyName = "Exotic oranges";
            product.Supplier = supplier;

            result = _productRepository.AddProduct(product);

            Product resultProduct = _productRepository.Find<Product>(x => x.ProductName == "Duvel Green")
                .FirstOrDefault();

            result = _productRepository.Update<Product>(resultProduct);

            Assert.IsTrue(result);
        }
        public void Transaction_AddEntityWithSingleTransactionAndDontCreateNewTransaction()
        {
            bool result = false;
            bool startNewTransaction = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddProduct(product);
            _productRepository.CommitTransaction(startNewTransaction);

            Assert.IsTrue(result);
        }
        public void Transaction_AddEntityWithoutTransaction()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddProductWithoutTransaction(product);

            Assert.IsTrue(result);
        }
        public void Transaction_AddWithoutCommitWithDeleteWithCommitAndUpdate()
        {
            bool result = false;

            Product product = new MockProduct()
                .CreateSingleProduct();

            result = _productRepository.AddProduct(product);
            result = _productRepository.DeleteProduct(product);

            product.ProductName = "Duvel Hop";
            result = _productRepository.UpdateProduct(product);

            Assert.IsTrue(result);
        }
        public void Transaction_AddMultipleEntitiesWithCommitPerAdd()
        {
            bool result = false;

            List<Product> products = new MockProduct().CreateMultipleProducts(5000);

            result = _productRepository.AddMultipleProductsWithCommit(products);

            Assert.IsTrue(result);
        }