/// <summary>
        /// Gets the product back-orderable information.
        /// </summary>
        /// <param name="shopName">The shop name.</param>
        /// <param name="productIds">The product ids.</param>
        /// <param name="visitorId">The visitor id.</param>
        /// <param name="location">The wharehouse location.</param>
        /// <returns>The products back-orderable information.</returns>
        public List <OrderableInformation> GetBackOrderableInformation(string shopName, IEnumerable <string> productIds, string visitorId, string location)
        {
            var request = new GetBackOrderableInformationRequest(shopName, productIds.Select(pid => new InventoryProduct {
                ProductId = pid
            }).ToList())
            {
                VisitorId = visitorId, Location = location
            };
            GetBackOrderableInformationResult result = this._serviceProvider.GetBackOrderableInformation(request);
            var orderableInfos = new List <OrderableInformation>();

            if (result == null)
            {
                return(orderableInfos);
            }

            foreach (var orderableInfo in productIds.Select(id => (result.OrderableInformation.FirstOrDefault(i => i.Product.ProductId.Equals(id, System.StringComparison.OrdinalIgnoreCase)) ?? new OrderableInformation {
                Product = new InventoryProduct {
                    ProductId = id
                }
            })).Where(orderableInfo => !orderableInfos.Contains(orderableInfo)))
            {
                orderableInfos.Add(orderableInfo);
            }

            return(orderableInfos);
        }
        public void ShouldNotAddNewRecordsIfProductBackOrderableInformationIsNotFound()
        {
            // Arrange
            var request = new GetBackOrderableInformationRequest("shopname", new List <InventoryProduct> {
                new InventoryProduct {
                    ProductId = "noExist"
                }
            });
            var result = new GetBackOrderableInformationResult();
            var args   = new ServicePipelineArgs(request, result);

            var results = new OrderableInformationModel[1];

            results[0] = null;
            this._client.GetBackOrderableInformationList("shopname", Arg.Is <string[]>(ids => (ids.Length == 1) && (ids[1] == "noExist")), new System.Guid()).Returns(results);

            // Act
            this._processor.Process(args);

            // Assert
            result.OrderableInformation.Should().HaveCount(1);
            result.OrderableInformation.ElementAt(0).Product.ProductId.Should().Be("noExist");
            result.OrderableInformation.ElementAt(0).Status.Should().Be(null);
            result.OrderableInformation.ElementAt(0).InStockDate.Should().Be(null);
            result.OrderableInformation.ElementAt(0).OrderableEndDate.Should().Be(null);
            result.OrderableInformation.ElementAt(0).OrderableStartDate.Should().Be(null);
            result.OrderableInformation.ElementAt(0).RemainingQuantity.Should().Be(0);
            result.OrderableInformation.ElementAt(0).ShippingDate.Should().Be(null);
            result.OrderableInformation.ElementAt(0).CartQuantityLimit.Should().Be(0);
        }
        public void ShouldGetBackOrderableInformationForTheSpecifiedProducts()
        {
            // Arrange
            var request = new GetBackOrderableInformationRequest("shopname", new List <InventoryProduct> {
                new InventoryProduct {
                    ProductId = "pid1"
                }
            });
            var result = new GetBackOrderableInformationResult();
            var args   = new ServicePipelineArgs(request, result);

            this._client.GetBackOrderableInformationList("shopname", Arg.Is <string[]>(ids => (ids.Length == 1) && (ids[0] == "pid1")), new System.Guid())
            .Returns(new[] { new OrderableInformationModel {
                                 ProductId = "pid1", Status = NopCommerce.NopInventoryService.StockStatus.InStock
                             } });

            // Act
            this._processor.Process(args);

            // Assert
            result.OrderableInformation.Should().HaveCount(1);
            result.OrderableInformation.ElementAt(0).Product.ProductId.Should().Be("pid1");
            result.OrderableInformation.ElementAt(0).Status.Should().Be(1);
        }