public CartService( IProductService productService, IPricingService pricingService, IOrderGroupFactory orderGroupFactory, CustomerContextFacade customerContext, IInventoryProcessor inventoryProcessor, IOrderRepository orderRepository, IPromotionEngine promotionEngine, IAddressBookService addressBookService, ICurrentMarket currentMarket, ICurrencyService currencyService, ReferenceConverter referenceConverter, IContentLoader contentLoader, IRelationRepository relationRepository, OrderValidationService orderValidationService) { _productService = productService; _pricingService = pricingService; _orderGroupFactory = orderGroupFactory; _customerContext = customerContext; _inventoryProcessor = inventoryProcessor; _promotionEngine = promotionEngine; _orderRepository = orderRepository; _addressBookService = addressBookService; _currentMarket = currentMarket; _currencyService = currencyService; _referenceConverter = referenceConverter; _contentLoader = contentLoader; _relationRepository = relationRepository; _orderValidationService = orderValidationService; }
public CheckoutController( ICurrencyService currencyService, ControllerExceptionHandler controllerExceptionHandler, IOrderRepository orderRepository, CheckoutViewModelFactory checkoutViewModelFactory, ICartService cartService, OrderSummaryViewModelFactory orderSummaryViewModelFactory, IRecommendationService recommendationService, CheckoutService checkoutService, OrderValidationService orderValidationService, IKlarnaPaymentsService klarnaPaymentsService, IKlarnaCheckoutService klarnaCheckoutService, IContentLoader contentLoader, IMarketService marketService) { _currencyService = currencyService; _controllerExceptionHandler = controllerExceptionHandler; _orderRepository = orderRepository; _checkoutViewModelFactory = checkoutViewModelFactory; _cartService = cartService; _orderSummaryViewModelFactory = orderSummaryViewModelFactory; _recommendationService = recommendationService; _checkoutService = checkoutService; _orderValidationService = orderValidationService; _klarnaPaymentsService = klarnaPaymentsService; _klarnaCheckoutService = klarnaCheckoutService; _contentLoader = contentLoader; _marketService = marketService; }
public CheckoutController( ICurrencyService currencyService, ControllerExceptionHandler controllerExceptionHandler, IOrderRepository orderRepository, CheckoutViewModelFactory checkoutViewModelFactory, ICartService cartService, OrderSummaryViewModelFactory orderSummaryViewModelFactory, IRecommendationService recommendationService, CheckoutService checkoutService, OrderValidationService orderValidationService, IDatabaseMode databaseMode, ISwedbankPayCheckoutService swedbankPayCheckoutService, IContentLoader contentLoader, IMarketService marketService, IAddressBookService addressBookService) { _currencyService = currencyService; _controllerExceptionHandler = controllerExceptionHandler; _orderRepository = orderRepository; _checkoutViewModelFactory = checkoutViewModelFactory; _cartService = cartService; _orderSummaryViewModelFactory = orderSummaryViewModelFactory; _recommendationService = recommendationService; _checkoutService = checkoutService; _orderValidationService = orderValidationService; _databaseMode = databaseMode; _swedbankPayCheckoutService = swedbankPayCheckoutService; _contentLoader = contentLoader; _marketService = marketService; _addressBookService = addressBookService; }
public CheckoutController( ICurrencyService currencyService, ControllerExceptionHandler controllerExceptionHandler, IOrderRepository orderRepository, CheckoutViewModelFactory checkoutViewModelFactory, ICartService cartService, OrderSummaryViewModelFactory orderSummaryViewModelFactory, IRecommendationService recommendationService, CheckoutService checkoutService, OrderValidationService orderValidationService, IDatabaseMode databaseMode, SecureAcceptanceSecurity secureAcceptanceSecurity, IAddressBookService addressBookService) { _currencyService = currencyService; _controllerExceptionHandler = controllerExceptionHandler; _orderRepository = orderRepository; _checkoutViewModelFactory = checkoutViewModelFactory; _cartService = cartService; _orderSummaryViewModelFactory = orderSummaryViewModelFactory; _recommendationService = recommendationService; _checkoutService = checkoutService; _orderValidationService = orderValidationService; _databaseMode = databaseMode; _secureAcceptanceSecurity = secureAcceptanceSecurity; _addressBookService = addressBookService; }
public async Task WhenNoSubscriptionAndNoOrders_FreeReportAvailable() { var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new AccountModel() { UserId = "1234" }); Assert.AreEqual(ValidationState.FreeReportValid, result.State); Assert.AreEqual(1, result.RemainingOrders); }
public CreateOrdersStep(ICartService cartService, IOrderGroupCalculator orderGroupCalculator, IOrderGroupFactory orderGroupFactory, IOrderRepository orderRepository, OrderValidationService orderValidationService) { _cartService = cartService; _orderGroupCalculator = orderGroupCalculator; _orderGroupFactory = orderGroupFactory; _orderRepository = orderRepository; _orderValidationService = orderValidationService; }
public async Task WhenNoSubscriptionAndOneOrder_FreeTrialAvailable() { _orderCache.Put("1", new Order()); var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new AccountModel() { UserId = "1234" }); Assert.AreEqual(ValidationState.NoSubscriptionAndTrialValid, result.State); Assert.AreEqual(0, result.RemainingOrders); _refresher.Verify(x => x.RefreshCaches(It.IsAny <AccountModel>()), Times.Never); }
public async Task WhenNotUsingCached_ShouldRefreshCachesBeforeValidating() { var refresh = new Mock <ICacheRefresher>(); refresh.Setup(x => x.RefreshCaches(It.IsAny <AccountModel>())) .Returns(Task.Run(() => _orderCache.Put("1", new Order()))); var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new AccountModel() { UserId = "123" }, false); Assert.AreEqual(ValidationState.NoSubscriptionAndTrialValid, result.State); Assert.AreEqual(0, result.RemainingOrders); }
public async Task WhenPrevSubscriptionAndOneOrder_FreeTrialNotAvailable() { _subCache.Put("1", new SubscriptionModel() { EndDateTime = DateTimeOffset.Now.AddDays(-3) }); _orderCache.Put("1", new Order()); var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new AccountModel() { UserId = "1234" }); Assert.AreEqual(ValidationState.NoSubscriptionAndTrialAlreadyUsed, result.State); }
public QuickSilverCartAdapter(IContentLoaderWrapper contentLoaderWrapper, IOrderRepository orderRepository, IPromotionEngine promotionEngine, IVsfPriceService priceService, IMarketService marketService, IEnumerable <IPaymentMethod> paymentMethods, ShippingManagerFacade shippingManagerFacade, ReferenceConverter referenceConverter, OrderValidationService orderValidationService) { _contentLoaderWrapper = contentLoaderWrapper; _orderRepository = orderRepository; _promotionEngine = promotionEngine; _priceService = priceService; _marketService = marketService; _paymentMethods = paymentMethods; _shippingManagerFacade = shippingManagerFacade; _referenceConverter = referenceConverter; _orderValidationService = orderValidationService; }
public async Task WhenActiveSubscriptionAndAllOrdersUsed_ShouldNotValidate(SubscriptionType type) { _subCache.Put("1", new SubscriptionModel() { EndDateTime = DateTimeOffset.Now.AddDays(2), SubscriptionType = type, StartDateTime = DateTimeOffset.Now.AddDays(-20) }); _orderCache.Put(Enumerable.Range(0, SubscriptionUtility.GetInfoFromSubType(type).OrderCount + 1) .ToDictionary(x => x.ToString(), x => new Order() { DateReceived = DateTimeOffset.Now.AddDays(-2) })); var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new MobileClient.Authentication.AccountModel() { UserId = "234" }); Assert.AreEqual(ValidationState.NoReportsLeftInPeriod, result.State); }
public async Task WhenActiveSubscriptionAndRemainingOrders_ShouldHaveOrdersLeft(SubscriptionType type, int orderCount) { _subCache.Put("1", new SubscriptionModel() { EndDateTime = DateTimeOffset.Now.AddDays(2), SubscriptionType = type, StartDateTime = DateTimeOffset.Now.AddDays(-20) }); _orderCache.Put(Enumerable.Range(0, orderCount + 1) .ToDictionary(x => x.ToString(), x => new Order() { DateReceived = DateTimeOffset.Now.AddDays(-2) })); var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new AccountModel() { UserId = "12345" }); Assert.AreEqual(ValidationState.SubscriptionReportValid, result.State); Assert.AreEqual(SubscriptionUtility.GetInfoFromSubType(type).OrderCount - orderCount, result.RemainingOrders); }
public async Task WhenNotAllOrdersUsedFromOneSub_RollsOverToNextMonth(int totalOrders, ValidationState expected) { var subs = new List <SubscriptionModel>() { new SubscriptionModel() { PurchaseId = "1", EndDateTime = DateTimeOffset.Now.AddDays(2), SubscriptionType = SubscriptionType.Basic, StartDateTime = DateTimeOffset.Now.AddDays(-20) }, new SubscriptionModel() { PurchaseId = "2", EndDateTime = DateTimeOffset.Now.AddDays(-20), SubscriptionType = SubscriptionType.Premium, StartDateTime = DateTimeOffset.Now.AddDays(-40) }, new SubscriptionModel() { PurchaseId = "3", EndDateTime = DateTimeOffset.Now.AddDays(-40), SubscriptionType = SubscriptionType.Enterprise, StartDateTime = DateTimeOffset.Now.AddDays(-60) }, new SubscriptionModel() { PurchaseId = "4", EndDateTime = DateTimeOffset.Now.AddDays(-60), SubscriptionType = SubscriptionType.Basic, StartDateTime = DateTimeOffset.Now.AddDays(-80) } }; var prs = new List <PurchasedReportModel>() { new PurchasedReportModel() { PurchaseId = "1" }, new PurchasedReportModel() { PurchaseId = "2" } }; var purchasedOrderCount = subs.Select(x => SubscriptionUtility.GetInfoFromSubType(x.SubscriptionType).OrderCount).Sum() + prs.Count(); _subCache.Put(subs.ToDictionary(x => x.PurchaseId, x => x)); _prCache.Put(prs.ToDictionary(x => x.PurchaseId, x => x)); _orderCache.Put(Enumerable.Range(0, totalOrders + 1) .ToDictionary(x => x.ToString(), x => new Order() { Fulfilled = true, DateReceived = DateTimeOffset.Now.AddDays(-2) })); var valSvc = new OrderValidationService(_refresher.Object, _orderCache, _subCache, _prCache, _logger.Object); var result = await valSvc.ValidateOrderRequest(new MobileClient.Authentication.AccountModel() { UserId = "234" }); var expectedCount = purchasedOrderCount - totalOrders > 0 ? purchasedOrderCount - totalOrders : 0; Assert.AreEqual(expectedCount, result.RemainingOrders); Assert.AreEqual(expected, result.State); }
public OrdersController(ICachedReadOrdersRepository ordersRepository, OrderValidationService orderValidationService) { this.ordersRepository = ordersRepository; this.orderValidationService = orderValidationService; }