private ICartBuilder GetCartBuilder() { var catalogApi = GetCatalogApiClient(); var cartApi = GetCartApiClient(); var marketingApi = GetMarketingApiClient(); var inventoryApi = GetInventoryApiClient(); var pricingApi = GetPricingApiClient(); var searchApi = GetSearchApiClient(); var customerApi = GetCustomerApiClient(); var orderApi = GetOrderApiClient(); var quoteApi = GetQuoteApiClient(); var storeApi = GetStoreApiClient(); var cacheManager = new Mock <ILocalCacheManager>().Object; var workContextFactory = new Func <WorkContext>(GetTestWorkContext); var promotionEvaluator = new PromotionEvaluator(marketingApi); var pricingService = new PricingServiceImpl(pricingApi, null, promotionEvaluator); var customerService = new CustomerServiceImpl(workContextFactory, customerApi, orderApi, quoteApi, storeApi, null, cacheManager); var catalogSearchService = new CatalogSearchServiceImpl(workContextFactory, catalogApi, inventoryApi, searchApi, pricingService, customerService, null); var retVal = new CartBuilder(workContextFactory, cartApi, catalogSearchService, cacheManager, promotionEvaluator, null, null); return(retVal); }
private ICartBuilder GetCartBuilder() { var catalogApi = GetCatalogApiClient(); var cartApi = GetCartApiClient(); var marketingApi = GetMarketingApiClient(); var inventoryApi = GetInventoryApiClient(); var pricingApi = GetPricingApiClient(); var customerApi = GetCustomerApiClient(); var orderApi = GetOrderApiClient(); var quoteApi = GetQuoteApiClient(); var storeApi = GetStoreApiClient(); var cacheManager = new Mock <ILocalCacheManager>().Object; var workContextFactory = new Func <WorkContext>(GetTestWorkContext); var promotionEvaluator = new PromotionEvaluator(marketingApi); var inventoryService = new Mock <IInventoryService>().Object; var pricingService = new PricingServiceImpl(pricingApi, GetTaxEvaluator(), promotionEvaluator, inventoryService); var customerService = new CustomerServiceImpl(workContextFactory, customerApi, orderApi, quoteApi, storeApi, GetSubscriptionModuleApiClient(), cacheManager); var catalogSearchService = new CatalogSearchServiceImpl(workContextFactory, catalogApi, inventoryApi, pricingService, customerService, GetSubscriptionModuleApiClient(), GetProductAvailabilityService(), inventoryService); var retVal = new CartBuilder(workContextFactory, cartApi, catalogSearchService, cacheManager, promotionEvaluator, GetTaxEvaluator(), GetSubscriptionModuleApiClient(), GetProductAvailabilityService()); return(retVal); }
private static PricingModuleController GetController() { Func <IPricingRepository> repositoryFactory = () => { return(new PricingRepositoryImpl("VirtoCommerce", new EntityPrimaryKeyGeneratorInterceptor(), new AuditableInterceptor())); }; var pricingService = new PricingServiceImpl(repositoryFactory, null); var controller = new PricingModuleController(pricingService, null, null, null); return(controller); }
private ICatalogSearchService GetCatalogSearchService() { var apiClientConfiguration = new Client.Client.Configuration(GetApiClient()); var workContextFactory = new Func <WorkContext>(GetTestWorkContext); var catalogApi = new CatalogModuleApi(apiClientConfiguration); var pricingApi = new PricingModuleApi(apiClientConfiguration); var pricingService = new PricingServiceImpl(workContextFactory, pricingApi); var inventoryApi = new InventoryModuleApi(apiClientConfiguration); var searchApi = new SearchModuleApi(apiClientConfiguration); var marketingApi = new MarketingModuleApi(apiClientConfiguration); var promotionEvaluator = new PromotionEvaluator(marketingApi); return(new CatalogSearchServiceImpl(workContextFactory, catalogApi, pricingService, inventoryApi, searchApi, promotionEvaluator)); }
private ICatalogSearchService GetCatalogSearchService() { var catalogApi = GetCatalogApiClient(); var commerceApi = GetCoreApiClient(); var inventoryApi = GetInventoryApiClient(); var marketingApi = GetMarketingApiClient(); var pricingApi = GetPricingApiClient(); var searchApi = GetSearchApiClient(); var workContextFactory = new Func <WorkContext>(GetTestWorkContext); var pricingService = new PricingServiceImpl(workContextFactory, pricingApi, commerceApi); var promotionEvaluator = new PromotionEvaluator(marketingApi); var result = new CatalogSearchServiceImpl(workContextFactory, catalogApi, pricingService, inventoryApi, searchApi, promotionEvaluator); return(result); }
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 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, cacheManager.Object); return(retVal); }
private ICartBuilder GetCartBuilder() { var catalogModuleApi = GetCatalogApiClient(); var cartApi = GetCartApiClient(); var commerceApi = GetCoreApiClient(); var marketingApi = GetMarketingApiClient(); var inventoryApi = GetInventoryApiClient(); var pricingApi = GetPricingApiClient(); var searchApi = GetSearchApiClient(); var cacheManager = new Moq.Mock <ILocalCacheManager>(); var workContextFactory = new Func <WorkContext>(GetTestWorkContext); var promotionEvaluator = new PromotionEvaluator(marketingApi); var pricingService = new PricingServiceImpl(workContextFactory, pricingApi, commerceApi); var catalogSearchService = new CatalogSearchServiceImpl(workContextFactory, catalogModuleApi, pricingService, inventoryApi, searchApi, promotionEvaluator); var retVal = new CartBuilder(cartApi, promotionEvaluator, catalogSearchService, commerceApi, cacheManager.Object); return(retVal); }
public void Can_return_price_from_many_prices_with_start_and_end_date() { var evalContext = new PriceEvaluationContext { ProductIds = new[] { "ProductId" }, PricelistIds = new[] { "List1" } }; var mockPrices = new PriceEntity[] { // Unbounded past. new PriceEntity { Id = "1", List = 1, EndDate = new DateTime(2018, 09, 10), PricelistId = "List1", ProductId = "ProductId" }, // Bounded past. new PriceEntity { Id = "2", List = 2, StartDate = new DateTime(2018, 09, 15), EndDate = new DateTime(2018, 09, 17), PricelistId = "List1", ProductId = "ProductId" }, // Bounded future. new PriceEntity { Id = "3", List = 3, StartDate = new DateTime(2018, 09, 26), EndDate = new DateTime(2018, 09, 29), PricelistId = "List1", ProductId = "ProductId" }, // Unbounded future. new PriceEntity { Id = "4", List = 4, StartDate = new DateTime(2018, 10, 1), PricelistId = "List1", ProductId = "ProductId" }, // Default unfiltered price. new PriceEntity { Id = "10", List = 10, PricelistId = "List1", ProductId = "ProductId" }, }.AsQueryable().BuildMock(); var mockRepository = new Mock <IPricingRepository>(); mockRepository.SetupGet(x => x.Prices).Returns(mockPrices.Object); var service = new PricingServiceImpl(() => mockRepository.Object, null, null, null, null, new DefaultPricingPriorityFilterPolicy()); // Eval with date and no matches, this should result in default price. evalContext.CertainDate = new DateTime(2018, 09, 20); var prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(10, prices.Single().List); // Eval with date falling in bounded future. evalContext.CertainDate = new DateTime(2018, 09, 27); prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(3, prices.Single().List); // Eval with date falling in unbounded future. evalContext.CertainDate = new DateTime(2118, 10, 2); prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(4, prices.Single().List); // Eval with date falling in bounded past. evalContext.CertainDate = new DateTime(2018, 9, 16); prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(2, prices.Single().List); // Eval with date falling in unbounded past. evalContext.CertainDate = new DateTime(2018, 8, 1); prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(1, prices.Single().List); // Eval with current date, should result in unbounded future price. evalContext.CertainDate = DateTime.UtcNow; prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(4, prices.Single().List); // Eval without date, should result in unbounded future price. // This is also a backwards compatibilty test. // CertainDate was not used in previous price evaluation. Default to 'now' behaviour. evalContext.CertainDate = null; prices = service.EvaluateProductPricesAsync(evalContext).GetAwaiter().GetResult(); Assert.Equal(4, prices.Single().List); }