public CartController( ICartService cartService, IOrderRepository orderRepository, CartViewModelFactory cartViewModelFactory) { _cartService = cartService; _orderRepository = orderRepository; _cartViewModelFactory = cartViewModelFactory; }
public NavigationController( IContentLoader contentLoader, ICartService cartService, UrlHelper urlHelper, LocalizationService localizationService, CartViewModelFactory cartViewModelFactory) { _contentLoader = contentLoader; _cartService = cartService; _urlHelper = urlHelper; _localizationService = localizationService; _cartViewModelFactory = cartViewModelFactory; }
public CartViewModelFactoryTests() { _cart = new FakeCart(new MarketImpl(MarketId.Default), Currency.USD); _cart.Forms.Single().Shipments.Single().LineItems.Add(new InMemoryLineItem { Quantity = 1, PlacedPrice = 105, LineItemDiscountAmount = 5}); _startPage = new StartPage() { CheckoutPage = new ContentReference(1), WishListPage = new ContentReference(1) }; var contentLoaderMock = new Mock<IContentLoader>(); contentLoaderMock.Setup(x => x.Get<StartPage>(It.IsAny<ContentReference>())).Returns(_startPage); PreferredCultureAccessor accessor = () => CultureInfo.InvariantCulture; var shipmentViewModelFactoryMock = new Mock<ShipmentViewModelFactory>(null,null,null,null,null,null,accessor,null); _cartItems = new List<CartItemViewModel> {new CartItemViewModel {DiscountedPrice = new Money(100, Currency.USD), Quantity = 1} }; shipmentViewModelFactoryMock.Setup(x => x.CreateShipmentsViewModel(It.IsAny<ICart>())).Returns(() => new[] { new ShipmentViewModel {CartItems = _cartItems} }); var currencyServiceMock = new Mock<ICurrencyService>(); currencyServiceMock.Setup(x => x.GetCurrentCurrency()).Returns(Currency.USD); _totals = new OrderGroupTotals( new Money(100, Currency.USD), new Money(100, Currency.USD), new Money(100, Currency.USD), new Money(100, Currency.USD), new Money(100, Currency.USD), new Dictionary<IOrderForm, OrderFormTotals>()); var orderGroupTotalsCalculatorMock = new Mock<IOrderGroupTotalsCalculator>(); orderGroupTotalsCalculatorMock.Setup(x => x.GetTotals(It.IsAny<ICart>())).Returns(_totals); _orderDiscountTotal = new Money(5, Currency.USD); var orderGroupCalculatorMock = new Mock<IOrderGroupCalculator>(); orderGroupCalculatorMock.Setup(x => x.GetOrderDiscountTotal(It.IsAny<IOrderGroup>(), It.IsAny<Currency>())) .Returns(_orderDiscountTotal); orderGroupCalculatorMock.Setup(x => x.GetSubTotal(_cart)).Returns(new Money(_cart.GetAllLineItems().Sum(x => x.PlacedPrice * x.Quantity - ((ILineItemDiscountAmount)x).EntryAmount), _cart.Currency)); _subject = new CartViewModelFactory( contentLoaderMock.Object, currencyServiceMock.Object, orderGroupTotalsCalculatorMock.Object, orderGroupCalculatorMock.Object, shipmentViewModelFactoryMock.Object); }