/// <summary>
 /// Initializes a new instance of the <see cref="RemovePaymentInfoFromCartTest"/> class.
 /// </summary>
 public RemovePaymentInfoFromCartTest()
 {
   this._client = Substitute.For<ICartsServiceChannel>();
   var clientFactory = Substitute.For<ServiceClientFactory>();
   clientFactory.CreateClient<ICartsServiceChannel>(Arg.Any<string>(), Arg.Any<string>()).Returns(this._client);
   _processor = new NopCommerce.Pipelines.Carts.RemovePaymentInfo.RemovePaymentInfoFromCart() { ClientFactory = clientFactory };
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RemoveLinesFromCartTest"/> class.
        /// </summary>
        public RemoveLinesFromCartTest()
        {
            this.visitorId = Guid.NewGuid();

            this.cart = new Cart {
                ExternalId = this.visitorId.ToString(), Lines = new ReadOnlyCollectionAdapter <CartLine> {
                    new CartLine()
                }
            };
            this.lineToRemove = new CartLine
            {
                Product = new CartProduct
                {
                    ProductId = "100500",
                    Price     = new Price {
                        Amount = 100
                    }
                },
                Quantity = 12
            };

            this.request = new RemoveCartLinesRequest(this.cart, new[] { this.lineToRemove });
            this.result  = new CartResult();
            this.args    = new ServicePipelineArgs(this.request, this.result);

            this.client = Substitute.For <ICartsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new RemoveLinesFromCart {
                ClientFactory = clientFactory
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SaveCartTest"/> class.
        /// </summary>
        public SaveCartTest()
        {
            this.cart = new Cart {
                Lines = new ReadOnlyCollection <CartLine>(new List <CartLine> {
                    new CartLine {
                        Product = new CartProduct {
                            ProductId = "Audi S4"
                        }, Quantity = 5
                    },
                })
            };
            this.request = new SaveCartRequest(this.cart);
            this.result  = new CartResult();
            this.args    = new ServicePipelineArgs(this.request, this.result);

            this.client = Substitute.For <ICartsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new SaveCart {
                ClientFactory = clientFactory
            };
        }
    /// <summary>
    /// Changes the lines.
    /// </summary>
    /// <param name="cartModel">The cart model.</param>
    /// <param name="client">The client.</param>
    /// <param name="cartLine">The cart line.</param>
    /// <returns>The changed cart model.</returns>
    protected override ShoppingCartModel ChangeLines(ShoppingCartModel cartModel, ICartsServiceChannel client, CartLine cartLine)
    {
      if (cartLine.Product != null)
      {
        cartModel = client.UpdateQuantity(cartModel.CustomerGuid, cartLine.Product.ProductId, (int)cartLine.Quantity);
      }

      return cartModel;
    }
        public AddPartiesToCartTest()
        {
            _client = Substitute.For <ICartsServiceChannel>();
            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(_client);
            _processor = new AddPartiesToCart()
            {
                ClientFactory = clientFactory
            };
        }
Exemplo n.º 6
0
        public RemovePartiesFromCartTest()
        {
            visitorId = Guid.NewGuid();

            client = Substitute.For <ICartsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(client);

            processor = new RemovePartiesFromCart();
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetCartsTest" /> class.
        /// </summary>
        public GetCartsTest()
        {
            this.request = new GetCartsRequest("MyShop");
            this.result  = new GetCartsResult();
            this.args    = new ServicePipelineArgs(this.request, this.result);

            this.client = Substitute.For <ICartsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new GetCarts {
                ClientFactory = clientFactory
            };
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="LoadCartTest"/> class.
        /// </summary>
        public LoadCartTest()
        {
            this.visitorId = Guid.NewGuid();
            this.request   = new LoadCartRequest("NopShop", this.visitorId.ToString());
            this.result    = new CartResult();
            this.args      = new ServicePipelineArgs(this.request, this.result);

            this.client = Substitute.For <ICartsServiceChannel>();

            var clientFactory = Substitute.For <ServiceClientFactory>();

            clientFactory.CreateClient <ICartsServiceChannel>(Arg.Any <string>(), Arg.Any <string>()).Returns(this.client);

            this.processor = new LoadCart {
                ClientFactory = clientFactory
            };
        }
Exemplo n.º 9
0
        /// <summary>
        /// Changes the lines.
        /// </summary>
        /// <param name="cartModel">The cart model.</param>
        /// <param name="client">The client.</param>
        /// <param name="cartLine">The cart line.</param>
        /// <returns>The changed. cart model.</returns>
        protected override ShoppingCartModel ChangeLines(ShoppingCartModel cartModel, ICartsServiceChannel client, CartLine cartLine)
        {
            if (cartLine.Product != null)
            {
                cartModel = client.RemoveProduct(cartModel.CustomerGuid, cartLine.Product.ProductId);
            }

            return(cartModel);
        }