Exemplo n.º 1
0
        public void ReviseInventoriesStatusAsync_EbayServiceWithVariationFixedPriceItems_QuantityUpdatedForAll()
        {
            //A
            var ebayService = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox());

            //A
            var updateProductsAsyncTask1 = ebayService.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest>
            {
                new InventoryStatusRequest {
                    ItemId = ExistingProducts.FixedPrice1WithVariation1.ItemId, Sku = ExistingProducts.FixedPrice1WithVariation1.Sku, Quantity = ExistingProducts.FixedPrice1WithVariation1.Quantity + this.QtyUpdateFor
                },
                new InventoryStatusRequest {
                    ItemId = ExistingProducts.FixedPrice1WithVariation2.ItemId, Sku = ExistingProducts.FixedPrice1WithVariation2.Sku, Quantity = ExistingProducts.FixedPrice1WithVariation2.Quantity + this.QtyUpdateFor
                },
            }, new Guid().ToString());

            updateProductsAsyncTask1.Wait();
            var updateProductsAsyncTask2 = ebayService.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest>
            {
                ExistingProducts.FixedPrice1WithVariation1,
                ExistingProducts.FixedPrice1WithVariation2,
            }, new Guid().ToString());

            updateProductsAsyncTask2.Wait();

            //A
            (updateProductsAsyncTask1.Result.ToList().First(x => x.Items[0].ItemId == ExistingProducts.FixedPrice1WithVariation1.ItemId).Items[0].Quantity - updateProductsAsyncTask2.Result.ToList().First(x => x.Items[0].ItemId == ExistingProducts.FixedPrice1WithVariation1.ItemId).Items[0].Quantity).Should().Be(this.QtyUpdateFor);
            (updateProductsAsyncTask1.Result.ToList().First(x => x.Items[0].ItemId == ExistingProducts.FixedPrice1WithVariation2.ItemId).Items[0].Quantity - updateProductsAsyncTask2.Result.ToList().First(x => x.Items[0].ItemId == ExistingProducts.FixedPrice1WithVariation2.ItemId).Items[0].Quantity).Should().Be(this.QtyUpdateFor);
        }
Exemplo n.º 2
0
        public void ReviseInventoriesStatusAsync_EbayServiceWithNonVariationFixedPriceItems_QuantityUpdatedForAll()
        {
            //A
            var ebayServiceLowLevel = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox());

            var ebayService = new EbayService(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox());

            var temp1 = ebayService.GetActiveProductsAsync(CancellationToken.None, true);

            temp1.Wait();
            var activeProducts = temp1.Result.Where(x => !x.IsItemWithVariations()).ToList();
            var activeProductWithoutVariations1 = activeProducts.Skip(0).First();
            var activeProductWithoutVariations2 = activeProducts.Skip(1).First();

            //A
            var updateProductsAsyncTask1 = ebayServiceLowLevel.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest>
            {
                new InventoryStatusRequest {
                    ItemId = activeProductWithoutVariations1.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations1.Quantity + this.QtyUpdateFor
                },
                new InventoryStatusRequest {
                    ItemId = activeProductWithoutVariations2.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations2.Quantity + this.QtyUpdateFor
                },
            }, new Guid().ToString());

            updateProductsAsyncTask1.Wait();

            var updateProductsAsyncTask2 = ebayServiceLowLevel.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest>
            {
                new InventoryStatusRequest {
                    ItemId = activeProductWithoutVariations1.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations1.Quantity
                },
                new InventoryStatusRequest {
                    ItemId = activeProductWithoutVariations2.ItemId.ToLongOrDefault(), Quantity = activeProductWithoutVariations2.Quantity
                },
            }, new Guid().ToString());

            updateProductsAsyncTask2.Wait();

            //A
            updateProductsAsyncTask1.Result.ToList().TrueForAll(x => x.Items.Count == 2).Should().Be(true);
            updateProductsAsyncTask2.Result.ToList().TrueForAll(x => x.Items.Count == 2).Should().Be(true);

            var item1Update1 = updateProductsAsyncTask1.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations1.ItemId.ToLongOrDefault(false)).First();
            var item1Update2 = updateProductsAsyncTask2.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations1.ItemId.ToLongOrDefault(false)).First();
            var item2Update1 = updateProductsAsyncTask1.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations2.ItemId.ToLongOrDefault(false)).First();
            var item2Update2 = updateProductsAsyncTask2.Result.ToList().First().Items.Where(x => x.ItemId == activeProductWithoutVariations2.ItemId.ToLongOrDefault(false)).First();

            (item1Update1.Quantity - item1Update2.Quantity).Should().Be(this.QtyUpdateFor);
            (item2Update1.Quantity - item2Update2.Quantity).Should().Be(this.QtyUpdateFor);
        }
Exemplo n.º 3
0
        public void ReviseInventoriesStatusAsync_ModelContsinsSymbolsThatMustBeReplaced_SybolsReplasedByAliasesInRequest()
        {
            //A
            var stubWebRequestService = Substitute.For <IWebRequestServices>();

            stubWebRequestService.GetResponseStreamAsync(Arg.Any <WebRequest>(), Arg.Any <string>(), CancellationToken.None).Returns(Task.FromResult(ReviseInventoryStatusResponse.Success.ToStream()));
            var ebayServiceLowLevel = new EbayServiceLowLevel(this._testEmptyCredentials.GetEbayUserCredentials(), this._testEmptyCredentials.GetEbayDevCredentials(), stubWebRequestService);

            //A
            Action act = () =>
            {
                var reviseFixedPriceItemAsync = ebayServiceLowLevel.ReviseInventoriesStatusAsync(new List <InventoryStatusRequest>
                {
                    new InventoryStatusRequest()
                    {
                        ItemId   = 1,
                        Quantity = 1,
                        Sku      = "some sku with &<>'\""
                    }
                }, "mark");
                reviseFixedPriceItemAsync.Wait();
            };

            //A
            act.ShouldNotThrow <Exception>();
            stubWebRequestService.Received(1).CreateServicePostRequestAsync(
                Arg.Any <string>(),
                Arg.Is <string>(x => new XmlDocument().TryParse(x)),
                Arg.Any <Dictionary <string, string> >(), CancellationToken.None, Arg.Any <string>());
        }