private static ShoppingCart PrepareCart() { var contentManager = new ContentManagerStub(Products.Cast <IContent>().Union(ProductAttributes)); var cartStorage = new FakeCartStorage(); var attributeService = new ProductAttributeService(contentManager); var attributeExtensionProviders = new List <IProductAttributeExtensionProvider> { new TextProductAttributeExtensionProvider(new ShapeFactoryStub()) }; var priceService = new PriceService(new IPriceProvider[0], attributeService); var attributeDriver = new ProductAttributesPartDriver(attributeService, attributeExtensionProviders); var cart = new ShoppingCart(contentManager, cartStorage, priceService, new[] { attributeDriver }, null, new Notifier()); return(cart); }
private static ShoppingCart PrepareCart(IWorkContextAccessor wca, IEnumerable <DiscountStub> discounts = null, IEnumerable <ITaxProvider> taxProviders = null) { var contentItems = discounts == null ? Products : Products.Cast <IContent>().Union(discounts); var contentManager = new ContentManagerStub(contentItems); var cartStorage = new FakeCartStorage(); var priceProviders = new IPriceProvider[] { new DiscountPriceProvider(contentManager, wca, Now) { DisplayUrlResolver = item => ((ProductStub)item).Path } }; var priceService = new PriceService(priceProviders, new ProductAttributeService(contentManager), new TieredPriceProvider(wca)); var cart = new ShoppingCart(contentManager, cartStorage, priceService, null, taxProviders, new Notifier()); return(cart); }
public static ShoppingCart PrepareCart( IEnumerable <DiscountStub> discounts, IEnumerable <ITaxProvider> taxProviders = null, bool applyProductDiscounts = false ) { var products = applyProductDiscounts ? ProductsWithDiscounts : Products; var contentItems = discounts == null ? products : products.Cast <IContent>().Union(discounts); var contentManager = new ContentManagerStub(contentItems); var cartStorage = new FakeCartStorage(); var priceProviders = new IPriceProvider[] { new DiscountPriceProvider(contentManager, WorkContextAccessor, Now) { DisplayUrlResolver = item => ((ProductStub)item).Path }, new ProductDiscountPriceProvider() }; var priceService = new PriceService(priceProviders, null); var cart = new ShoppingCart(contentManager, cartStorage, priceService, null, taxProviders, new Notifier()); FillCart(cart); return(cart); }