public ShoppingCartApiController(
     LoadCart loadCart,
     CreateCart createCart,
     LoadProductBaseData loadProductBaseData,
     LoadRetailOfferData loadRetailOfferData,
     IHttpContextAccessor httpContextAccessor)
 {
     this.loadCart            = loadCart;
     this.createCart          = createCart;
     this.loadProductBaseData = loadProductBaseData;
     this.loadRetailOfferData = loadRetailOfferData;
     this.httpContextAccessor = httpContextAccessor;
 }
コード例 #2
0
        /// <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
            };
        }
コード例 #3
0
 public static Result <Cart, ErrorType> GetCart(LoadCart loadCart, CreateCart createCart, int userId) =>
 loadCart(userId)
 .Match(
     onSome: cart => cart,
     onNone: () => createCart(userId));