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); }
public void ReviseFixedPriceItemAsync_ModelContsinsSymbolsThatMustBeReplaced_SybolsReplasedByAliasesInRequest() { //A var stubWebRequestService = Substitute.For <IWebRequestServices>(); stubWebRequestService.GetResponseStreamAsync(Arg.Any <WebRequest>(), Arg.Any <string>(), CancellationToken.None).Returns(Task.FromResult(ReviseFixedPriceItemResponse.Success.ToStream())); var ebayServiceLowLevel = new EbayServiceLowLevel(this._testEmptyCredentials.GetEbayUserCredentials(), this._testEmptyCredentials.GetEbayDevCredentials(), stubWebRequestService); //A Action act = () => { var reviseFixedPriceItemAsync = ebayServiceLowLevel.ReviseFixedPriceItemAsync(new ReviseFixedPriceItemRequest() { ItemId = 1, Quantity = 1, Sku = "some sku with &<>'\"" }, "mark", true); reviseFixedPriceItemAsync.Wait(); }; //A act.ShouldNotThrow <Exception>(); stubWebRequestService.Received().CreateServicePostRequestAsync( Arg.Any <string>(), Arg.Is <string>(x => new XmlDocument().TryParse(x)), Arg.Any <Dictionary <string, string> >(), CancellationToken.None, Arg.Any <string>()); }
public void GetSessionId_EbayServiceWithCorrectRuName_HookupSessionId() { //A var ebayService = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var sessionId = ebayService.GetSessionId(new Guid().ToString()); //A sessionId.Should().NotBeNullOrWhiteSpace(); }
public void GetOrdersAsync_EbayServiceWithExistingOrders_HookupOrders() { //A var ebayServiceLowLevel = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var ordersTask = ebayServiceLowLevel.GetOrdersAsync(ExistingOrdersCreatedInRange.DateFrom, ExistingOrdersCreatedInRange.DateTo, GetOrdersTimeRangeEnum.CreateTime); ordersTask.Wait(); //A ordersTask.Result.Orders.Count().Should().BeGreaterThan(0); }
public void GetOrdersAsync_GetByIdEbayServiceWithExistingOrders_HookupOrders() { //A var ebayServiceLowLevel = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var ordersTask = ebayServiceLowLevel.GetOrdersAsync("", ExistingOrdersIds.OrdersIds.ToArray()); ordersTask.Wait(); //A ordersTask.Result.Orders.Count().Should().BeGreaterThan(0); }
public void GetOrdersAsync_EbayServiceWithNotExistingOrders_EmptyOrdersCollection() { //A var ebayServiceLowLevel = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var ordersTask = ebayServiceLowLevel.GetOrdersAsync(NotExistingOrdersInRange.DateFrom, NotExistingOrdersInRange.DateTo, GetOrdersTimeRangeEnum.CreateTime); ordersTask.Wait(); //A ordersTask.Result.Orders.Count().Should().Be(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); }
public async Task CreateUploadJob_EbayServiceWithCorrectRuName_HookupSessionId() { //A var ebayServiceLowLevel = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var createuploadJobResponse = await ebayServiceLowLevel.CreateUploadJobAsync(Guid.NewGuid(), new Guid().ToString()).ConfigureAwait(false); var abortJobResponse = await ebayServiceLowLevel.AbortJobAsync(createuploadJobResponse.JobId, new Guid().ToString()).ConfigureAwait(false); //A createuploadJobResponse.Errors.Should().BeNull(); abortJobResponse.Errors.Should().BeNull(); }
public void GetItemAsync_EbayServiceWithExistingFixedPriceVariationProduct_HookupItemVariationsSku() { //A var ebayService = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var inventoryStat1Task = ebayService.GetItemAsync(ExistingProducts.FixedPrice1WithVariation1.ItemId.ToString(), new Guid().ToString()); inventoryStat1Task.Wait(); var inventoryStat1 = inventoryStat1Task.Result; //A inventoryStat1.Variations.TrueForAll(x => !string.IsNullOrWhiteSpace(x.Sku)).Should().BeTrue(); }
public void GetItemAsync_EbayServiceWithExistingFixedPriceVariationProduct_HookupItemId() { //A var ebayService = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var inventoryStat1Task = ebayService.GetItemAsync(ExistingProducts.FixedPrice1WithVariation1.ItemId.ToString(), new Guid().ToString()); inventoryStat1Task.Wait(); var inventoryStat1 = inventoryStat1Task.Result; //A inventoryStat1.ItemId.Should().Be(ExistingProducts.FixedPrice1WithVariation1.ItemId.ToString()); }
public void FetchToken_EbayServiceWithCorrectRuName_HookupToken() { ////Attention!!! This code will regenerate youe credentials!!! //A var ebayService = new EbayServiceLowLevel(this._credentials.GetEbayUserCredentials(), this._credentials.GetEbayConfigSandbox()); //A var sessionId = ebayService.GetSessionId(new Guid().ToString()); ebayService.AuthenticateUser(sessionId); var userToken = ebayService.FetchToken(sessionId, new Guid().ToString()); //A sessionId.Should().NotBeNullOrWhiteSpace(); userToken.Should().NotBeNullOrWhiteSpace(); }
public void GetSellerListAsync_EbayServiceWithExistingItems_NotEmptyItemsCollection() { //A using (var fs = new FileStream(@".\Files\GetSellerListResponse\EbayServiceGetSellerListResponseWith5ItemsWithSku_DetailLevelAll.xml", FileMode.Open, FileAccess.Read)) { var stubWebRequestService = Substitute.For <IWebRequestServices>(); stubWebRequestService.GetResponseStreamAsync(Arg.Any <WebRequest>(), Arg.Any <string>(), CancellationToken.None).Returns(Task.Factory.StartNew <Stream>(() => fs)); var ebayService = new EbayServiceLowLevel(this._testEmptyCredentials.GetEbayUserCredentials(), this._testEmptyCredentials.GetEbayDevCredentials(), stubWebRequestService); //A var getSellerListTask = ebayService.GetSellerListAsync(new DateTime(2014, 1, 1, 0, 0, 0), new DateTime(2014, 1, 28, 10, 0, 0), GetSellerListTimeRangeEnum.StartTime, new Guid().ToString()); getSellerListTask.Wait(); var items = getSellerListTask.Result; //A items.Items.Count().Should().Be(5, "because on site there are 5 items started in specified time"); } }
public void GetOrdersAsync_EbayServiceRespondContainsTotalNumberOfEntitiesZeroAndHasMoreOrdersFalse_Only1WebRequestServiceCallMaked() { //A string respstring; using (var fs = new FileStream(@".\Files\GetOrdersResponse\EbayServiceGetOrdersResponseWithTotalNumberOfEntities0AndHasMoreOrdersFalse.xml", FileMode.Open, FileAccess.Read)) respstring = new StreamReader(fs).ReadToEnd(); var getResponseStreamAsyncCallCounter = 0; var stubWebRequestService = Substitute.For <IWebRequestServices>(); stubWebRequestService.GetResponseStreamAsync(Arg.Any <WebRequest>(), Arg.Any <string>(), CancellationToken.None).Returns(Task.FromResult(respstring.ToStream())).AndDoes(x => getResponseStreamAsyncCallCounter++); var ebayService = new EbayServiceLowLevel(this._testEmptyCredentials.GetEbayUserCredentials(), this._testEmptyCredentials.GetEbayDevCredentials(), stubWebRequestService); //A var ordersTask = ebayService.GetOrdersAsync(new DateTime(2014, 1, 1, 0, 0, 0), new DateTime(2014, 1, 21, 10, 0, 0), GetOrdersTimeRangeEnum.CreateTime); ordersTask.Wait(); var orders = ordersTask.Result; //A getResponseStreamAsyncCallCounter.Should().Be(1); }