예제 #1
0
 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<ICacheManager<object>>();
     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;
 }
        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 defautStore = allStores.FirstOrDefault(x => string.Equals(x.Id, "Electronics", StringComparison.InvariantCultureIgnoreCase));
            var currencies = commerceApi.CommerceGetAllCurrencies().Select(x => x.ToWebModel(defautStore.DefaultLanguage));
            defautStore.SyncCurrencies(currencies, defautStore.DefaultLanguage);

            var retVal = new WorkContext
            {
                AllCurrencies = defautStore.Currencies,
                CurrentLanguage = defautStore.DefaultLanguage,
                CurrentCurrency = defautStore.DefaultCurrency,
                CurrentStore = defautStore
            };
            return retVal;
        }