public void PutStockItemAsync_StoreContainsProducts_ProductsUpdated(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository   = new IntegrationAdminTokenRepository(testCase.Url);
            var token             = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository = new ProductRepository(token, testCase.Url);
            var stockRepository   = new CatalogStockItemRepository(token, testCase.Url);

            var products  = productRepository.GetProductsAsync(DateTime.MinValue, new PagingModel(5, 1)).WaitResult();
            var stockItem = stockRepository.GetStockItemAsync(products.items.First().sku).WaitResult();
            //------------ Act
            var stockItem2 = stockRepository.PutStockItemAsync(products.items.First().sku, stockItem.itemId.Value.ToString(), new RootObject {
                stockItem = new StockItem {
                    qty = 100, isInStock = true
                }
            }).WaitResult();
            var stockItem2Updated = stockRepository.GetStockItemAsync(products.items.First().sku).WaitResult();

            var stockItem3 = stockRepository.PutStockItemAsync(products.items.First().sku, stockItem.itemId.Value.ToString(), new RootObject {
                stockItem = new StockItem {
                    qty = 100500, isInStock = false
                }
            }).WaitResult();
            var stockItem3Updated = stockRepository.GetStockItemAsync(products.items.First().sku).WaitResult();

            //------------ Assert
            stockItem2.Should().Be(true);
            stockItem3.Should().Be(true);
            stockItem2Updated.qty.Value.Should().Be(100);
            stockItem2Updated.isInStock.Value.Should().Be(true);
            stockItem3Updated.qty.Value.Should().Be(100500);
            stockItem3Updated.isInStock.Value.Should().Be(false);
        }
        public void PutStockItemsAsync_StoreContainsProducts_ProductsUpdated(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository   = new IntegrationAdminTokenRepository(testCase.Url);
            var token             = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository = new ProductRepository(token, testCase.Url);
            var stockRepository   = new CatalogStockItemRepository(token, testCase.Url);

            var products   = productRepository.GetProductsAsync(DateTime.MinValue, "simple", new PagingModel(5, 1)).WaitResult();
            var stockItems = stockRepository.GetStockItemsAsync(products.items.Select(x => x.sku)).WaitResult();
            //------------ Act
            var stockItem2 = stockRepository.PutStockItemsAsync(products.items.Select(x => Tuple.Create(x.sku, x.id.ToString(), new RootObject {
                stockItem = new StockItem {
                    qty = 100, isInStock = true
                }
            }))).WaitResult();
            var stockItem2Updated = stockRepository.GetStockItemsAsync(products.items.Select(x => x.sku)).WaitResult();

            var stockItem3 = stockRepository.PutStockItemsAsync(products.items.Select(x => Tuple.Create(x.sku, x.id.ToString(), new RootObject {
                stockItem = new StockItem {
                    qty = 100500, isInStock = false
                }
            }))).WaitResult();
            var stockItem3Updated = stockRepository.GetStockItemsAsync(products.items.Select(x => x.sku)).WaitResult();

            //------------ Assert
            stockItem2.Should().OnlyContain(x => x);
            stockItem3.Should().OnlyContain(x => x);
            stockItem2Updated.Should().OnlyContain(x => x.qty == 100);
            stockItem2Updated.Should().OnlyContain(x => x.isInStock == true);
            stockItem3Updated.Should().OnlyContain(x => x.qty == 100500);
            stockItem3Updated.Should().OnlyContain(x => x.isInStock == false);
            products.items.Should().OnlyContain(x => x.typeId == "simple");
        }
Beispiel #3
0
        public void GetOrdersAsync_StoreContainsOrders_ReceiveOrders(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository        = new IntegrationAdminTokenRepository(testCase.Url);
            var tokenTask              = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var salesOrderRepositoryV1 = new SalesOrderRepositoryV1(tokenTask, testCase.Url);

            //------------ Act
            var items = salesOrderRepositoryV1.GetOrdersAsync(DateTime.MinValue, DateTime.UtcNow).WaitResult();

            //------------ Assert
            tokenTask.Token.Should().NotBeNullOrWhiteSpace();
            items.SelectMany(x => x.items).Count().Should().Be(items.First().total_count);
        }
        public void GetProductsManufacturers(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository   = new IntegrationAdminTokenRepository(testCase.Url);
            var token             = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository = new ProductRepository(token, testCase.Url);

            //------------ Act
            var productsManufacturers = productRepository.GetManufacturersAsync().WaitResult();

            //------------ Assert
            token.Token.Should().NotBeNullOrWhiteSpace();
            productsManufacturers.Should().NotBeNull();
            productsManufacturers.options.Count.Should().BeGreaterThan(0);
        }
        public void GetProductsByDefaultFilter_StoreContainsProducts_ReceiveProducts(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository   = new IntegrationAdminTokenRepository(testCase.Url);
            var token             = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository = new ProductRepository(token, testCase.Url);

            //------------ Act
            var productPages = productRepository.GetProductsAsync(DateTime.MinValue, null, false).WaitResult();

            //------------ Assert
            token.Token.Should().NotBeNullOrWhiteSpace();
            productPages.Count.Should().BeGreaterOrEqualTo(0);
            productPages.Any(page => page.items.Any(i => i.sku == null)).Should().BeFalse();
        }
        public void GetProducts_StoreContainsProducts_ReceiveProducts(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository   = new IntegrationAdminTokenRepository(testCase.Url);
            var token             = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository = new ProductRepository(token, testCase.Url);

            //------------ Act
            var products = productRepository.GetProductsAsync().WaitResult();

            //------------ Assert
            token.Token.Should().NotBeNullOrWhiteSpace();
            products.Count.Should().BeGreaterOrEqualTo(0);
            products.SelectMany(x => x.items).Count().Should().BeGreaterThan(0);
        }
Beispiel #7
0
        public void GetOrdersAsync_StoreContainsOrders_ReceivPage(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository        = new IntegrationAdminTokenRepository(testCase.Url);
            var token                  = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var salesOrderRepositoryV1 = new SalesOrderRepositoryV1(token, testCase.Url);
            var itemsPerPage           = 5;

            //------------ Act
            var orders = salesOrderRepositoryV1.GetOrdersAsync(new DateTime(2012, 1, 1), DateTime.UtcNow.AddDays(1), new PagingModel(itemsPerPage, 1)).WaitResult();

            //------------ Assert
            token.Token.Should().NotBeNullOrWhiteSpace();
            orders.items.Count.Should().BeGreaterOrEqualTo(1);
            orders.items.Count.Should().BeLessOrEqualTo(itemsPerPage);
        }
Beispiel #8
0
        public void GetOrdersAsync_StoreContainsOrders_ReceiveOrdersByIdReceivePage(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository        = new IntegrationAdminTokenRepository(testCase.Url);
            var tokenTask              = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var salesOrderRepositoryV1 = new SalesOrderRepositoryV1(tokenTask, testCase.Url);
            var itemsPerPage           = 5;

            //------------ Act
            var items  = salesOrderRepositoryV1.GetOrdersAsync(DateTime.MinValue, DateTime.UtcNow, new PagingModel(itemsPerPage, 1)).WaitResult();
            var items2 = salesOrderRepositoryV1.GetOrdersAsync(items.items.Select(x => x.increment_id), new PagingModel(itemsPerPage, 1)).WaitResult();

            //------------ Assert
            tokenTask.Token.Should().NotBeNullOrWhiteSpace();
            items2.items.Count.Should().BeGreaterOrEqualTo(1);
            items2.items.Count.Should().Be(items.items.Count);
        }
        public void GetProductsByType_StoreContainsProducts_ReceiveProducts(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository   = new IntegrationAdminTokenRepository(testCase.Url);
            var token             = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository = new ProductRepository(token, testCase.Url);

            //------------ Act
            var simpleProducts = productRepository.GetProductsAsync(DateTime.MinValue, "simple").WaitResult();
            var bundleProducts = productRepository.GetProductsAsync(DateTime.MinValue, "bundle").WaitResult();

            //------------ Assert
            token.Token.Should().NotBeNullOrWhiteSpace();
            simpleProducts.SelectMany(x => x.items).Count().Should().BeGreaterThan(0);
            bundleProducts.SelectMany(x => x.items).Count().Should().BeGreaterThan(0);
            simpleProducts.SelectMany(x => x.items).Should().OnlyContain(x => x.typeId == "simple");
            bundleProducts.SelectMany(x => x.items).Should().OnlyContain(x => x.typeId == "bundle");
        }
        public void GetProductsByUpdatedAt_StoreContainsProducts_ReceiveProducts(RepositoryTestCase testCase)
        {
            //------------ Arrange
            var adminRepository         = new IntegrationAdminTokenRepository(testCase.Url);
            var token                   = adminRepository.GetTokenAsync(testCase.MagentoLogin, testCase.MagentoPass).WaitResult();
            var productRepository       = new ProductRepository(token, testCase.Url);
            var products                = productRepository.GetProductsAsync().WaitResult();
            var allproductsSortedByDate = products.SelectMany(x => x.items).OrderBy(y => y.updatedAt);
            var date = allproductsSortedByDate.Skip(allproductsSortedByDate.Count() / 2).First().updatedAt;

            //------------ Act
            var productsUpdatedAt = productRepository.GetProductsAsync(date.ToDateTimeOrDefault()).WaitResult();

            //------------ Assert
            token.Token.Should().NotBeNullOrWhiteSpace();
            products.Count.Should().BeGreaterOrEqualTo(0);
            products.Count.Should().BeGreaterOrEqualTo(productsUpdatedAt.Count);
            products.SelectMany(x => x.items).Count().Should().BeGreaterThan(0);
        }