Ejemplo n.º 1
0
 public CartViewModelFactory(
     IContentLoader contentLoader,
     ICurrencyService currencyService,
     IOrderGroupCalculator orderGroupCalculator,
     ShipmentViewModelFactory shipmentViewModelFactory)
 {
     _contentLoader            = contentLoader;
     _currencyService          = currencyService;
     _orderGroupCalculator     = orderGroupCalculator;
     _shipmentViewModelFactory = shipmentViewModelFactory;
 }
Ejemplo n.º 2
0
 public CartViewModelFactory(
     IContentLoader contentLoader, 
     ICurrencyService currencyService, 
     IOrderGroupTotalsCalculator orderGroupTotalsCalculator, 
     IOrderGroupCalculator orderGroupCalculator, 
     ShipmentViewModelFactory shipmentViewModelFactory)
 {
     _contentLoader = contentLoader;
     _currencyService = currencyService;
     _orderGroupTotalsCalculator = orderGroupTotalsCalculator;
     _orderGroupCalculator = orderGroupCalculator;
     _shipmentViewModelFactory = shipmentViewModelFactory;
 }
Ejemplo n.º 3
0
 public CartViewModelFactory(
     IContentLoader contentLoader,
     IPricingService pricingService,
     IOrderGroupCalculator orderGroupCalculator,
     ShipmentViewModelFactory shipmentViewModelFactory,
     ReferenceConverter referenceConverter)
 {
     _contentLoader            = contentLoader;
     _pricingService           = pricingService;
     _orderGroupCalculator     = orderGroupCalculator;
     _shipmentViewModelFactory = shipmentViewModelFactory;
     _referenceConverter       = referenceConverter;
 }
 public MultiShipmentViewModelFactory(
     LocalizationService localizationService,
     IAddressBookService addressBookService,
     IContentLoader contentLoader,
     UrlResolver urlResolver,
     ServiceAccessor<HttpContextBase> httpContextAccessor,
     ShipmentViewModelFactory shipmentViewModelFactory)
 {
     _localizationService = localizationService;
     _addressBookService = addressBookService;
     _contentLoader = contentLoader;
     _urlResolver = urlResolver;
     _httpContextAccessor = httpContextAccessor;
     _shipmentViewModelFactory = shipmentViewModelFactory;
 }
 public CheckoutViewModelFactory(
     LocalizationService localizationService,
     PaymentMethodViewModelFactory paymentMethodViewModelFactory,
     IAddressBookService addressBookService,
     IContentLoader contentLoader,
     IOrderFactory orderFactory,
     UrlResolver urlResolver,
     ServiceAccessor<HttpContextBase> httpContextAccessor,
     ShipmentViewModelFactory shipmentViewModelFactory)
 {
     _localizationService = localizationService;
     _paymentMethodViewModelFactory = paymentMethodViewModelFactory;
     _addressBookService = addressBookService;
     _contentLoader = contentLoader;
     _orderFactory = orderFactory;
     _urlResolver = urlResolver;
     _httpContextAccessor = httpContextAccessor;
     _shipmentViewModelFactory = shipmentViewModelFactory;
 }
        public ShipmentViewModelFactoryTests()
        {
            _cart = new FakeCart(new MarketImpl(new MarketId(Currency.USD)), Currency.USD) { Name = "Default" };
            _cart.Forms.Single().Shipments.Single().LineItems.Add(new InMemoryLineItem { Code = "code"});
            _cart.Forms.Single().CouponCodes.Add("couponcode");

            var shippingManagerFacadeMock = new Mock<ShippingManagerFacade>();
            shippingManagerFacadeMock.Setup(x => x.GetShippingMethodsByMarket(It.IsAny<string>(), It.IsAny<bool>())).Returns(() => new List<ShippingMethodInfoModel>
            {
                new ShippingMethodInfoModel
                {
                    LanguageId = CultureInfo.InvariantCulture.TwoLetterISOLanguageName,
                    Currency = Currency.USD
                }
            });
            _shippingRate = new ShippingRate(Guid.NewGuid(), "name", new Money(10, Currency.USD));
            shippingManagerFacadeMock.Setup(x => x.GetRate(It.IsAny<IShipment>(), It.IsAny<ShippingMethodInfoModel>(), It.IsAny<IMarket>()))
                .Returns(_shippingRate);

            var languageServiceMock = new Mock<LanguageService>(null, null, null, null);
            languageServiceMock.Setup(x => x.GetCurrentLanguage()).Returns(CultureInfo.InvariantCulture);

            var referenceConverterMock = new Mock<ReferenceConverter>(null,null);

            var addressBookServiceMock = new Mock<IAddressBookService>();
            _addressModel = new AddressModel();
            addressBookServiceMock.Setup(x => x.ConvertToModel(It.IsAny<IOrderAddress>())).Returns(_addressModel);

            _cartItem = new CartItemViewModel ();
            var cartItemViewModelFactoryMock = new Mock<CartItemViewModelFactory>(null,null,null,null,null,null,null,null,null,null, null);
            cartItemViewModelFactoryMock.Setup(x => x.CreateCartItemViewModel(It.IsAny<ICart>(), It.IsAny<ILineItem>(), It.IsAny<VariationContent>())).Returns(_cartItem);

            var contentLoaderMock = new Mock<IContentLoader>();
            contentLoaderMock.Setup(x => x.GetItems(It.IsAny<IEnumerable<ContentReference>>(), It.IsAny<CultureInfo>()))
                .Returns(() => new List<VariationContent> {new VariationContent {Code = "code"} });

            var relationRepositoryMock = new Mock<IRelationRepository>();
            relationRepositoryMock.Setup(x => x.GetRelationsByTarget<ProductVariation>(It.IsAny<ContentReference>()))
                .Returns(() => new[] {new ProductVariation {Source = new ContentReference(1)}});

            _subject = new ShipmentViewModelFactory(
                contentLoaderMock.Object,
                shippingManagerFacadeMock.Object,
                languageServiceMock.Object,
                referenceConverterMock.Object,
                addressBookServiceMock.Object,
                cartItemViewModelFactoryMock.Object,
                () => CultureInfo.GetCultureInfo("en"),
                relationRepositoryMock.Object);    
        }