protected WorkContext GetTestWorkContext() { var apiClientCfg = new Client.Client.Configuration(GetApiClient()); var storeApi = new StoreModuleApi(apiClientCfg); var commerceApi = new CommerceCoreModuleApi(apiClientCfg); var allStores = storeApi.StoreModuleGetStores().Select(x => x.ToWebModel()); var defaultStore = allStores.FirstOrDefault(x => string.Equals(x.Id, "Electronics", StringComparison.InvariantCultureIgnoreCase)); var currencies = commerceApi.CommerceGetAllCurrencies().Select(x => x.ToWebModel(defaultStore.DefaultLanguage)); defaultStore.SyncCurrencies(currencies, defaultStore.DefaultLanguage); var retVal = new WorkContext { AllCurrencies = defaultStore.Currencies, CurrentLanguage = defaultStore.DefaultLanguage, CurrentCurrency = defaultStore.DefaultCurrency, CurrentStore = defaultStore, CurrentCart = new Model.Cart.ShoppingCart(defaultStore.DefaultCurrency, defaultStore.DefaultLanguage), CurrentCustomer = new CustomerInfo { Id = Guid.NewGuid().ToString() } }; return(retVal); }
private ICartBuilder GetCartBuilder() { var apiClientCfg = new Client.Client.Configuration(GetApiClient()); var marketingApi = new MarketingModuleApi(apiClientCfg); var cartApi = new ShoppingCartModuleApi(apiClientCfg); var cacheManager = new Moq.Mock <ILocalCacheManager>(); var workContextFactory = new Func <WorkContext>(GetTestWorkContext); var promotionEvaluator = new PromotionEvaluator(marketingApi); var catalogModuleApi = new CatalogModuleApi(apiClientCfg); var pricingApi = new PricingModuleApi(apiClientCfg); var commerceApi = new CommerceCoreModuleApi(apiClientCfg); var pricingService = new PricingServiceImpl(workContextFactory, pricingApi); var inventoryApi = new InventoryModuleApi(apiClientCfg); var searchApi = new SearchModuleApi(apiClientCfg); var catalogSearchService = new CatalogSearchServiceImpl(workContextFactory, catalogModuleApi, pricingService, inventoryApi, searchApi, promotionEvaluator); var retVal = new CartBuilder(cartApi, promotionEvaluator, catalogSearchService, commerceApi, cacheManager.Object); return(retVal); }