Example #1
0
            public ProductViewModelFactoryWithTestGetLookupImageUrl(
                IViewModelMapper viewModelMapper,
                IProductRepository productRepository,
                IDamProvider damProvider,
                ILocalizationProvider localizationProvider,
                ILookupService lookupService,
                IProductUrlProvider productUrlProvider,
                IScopeViewService scopeViewService,
                IRecurringOrdersRepository recurringOrdersRepository,
                IRecurringOrderProgramViewModelFactory recurringOrderProgramViewModelFactory,
                IRecurringOrdersSettings recurringOrdersSettings,
                IProductSpecificationsViewService productSpecificationsViewService,
                IMyAccountUrlProvider myAccountUrlProvider)

                : base(
                    viewModelMapper,
                    productRepository,
                    damProvider,
                    localizationProvider,
                    lookupService,
                    productUrlProvider,
                    scopeViewService,
                    recurringOrdersRepository,
                    recurringOrderProgramViewModelFactory,
                    recurringOrdersSettings,
                    productSpecificationsViewService,
                    myAccountUrlProvider)
            {
            }
Example #2
0
 public ProductViewModelFactory(
     IViewModelMapper viewModelMapper,
     IProductRepository productRepository,
     IDamProvider damProvider,
     ILocalizationProvider localizationProvider,
     ILookupService lookupService,
     IProductUrlProvider productUrlProvider,
     IScopeViewService scopeViewService,
     IRecurringOrdersRepository recurringOrdersRepository,
     IRecurringOrderProgramViewModelFactory recurringOrderProgramViewModelFactory,
     IRecurringOrdersSettings recurringOrdersSettings,
     IProductSpecificationsViewService productSpecificationsViewService,
     IMyAccountUrlProvider myAccountUrlProvider)
 {
     ViewModelMapper                       = viewModelMapper ?? throw new ArgumentNullException(nameof(viewModelMapper));
     ProductRepository                     = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
     DamProvider                           = damProvider ?? throw new ArgumentNullException(nameof(damProvider));
     LocalizationProvider                  = localizationProvider ?? throw new ArgumentNullException(nameof(localizationProvider));
     LookupService                         = lookupService ?? throw new ArgumentNullException(nameof(lookupService));
     ProductUrlProvider                    = productUrlProvider ?? throw new ArgumentNullException(nameof(productUrlProvider));
     ScopeViewService                      = scopeViewService ?? throw new ArgumentNullException(nameof(scopeViewService));
     RecurringOrdersRepository             = recurringOrdersRepository ?? throw new ArgumentNullException(nameof(recurringOrdersRepository));
     RecurringOrderProgramViewModelFactory = recurringOrderProgramViewModelFactory ?? throw new ArgumentNullException(nameof(recurringOrderProgramViewModelFactory));
     RecurringOrdersSettings               = recurringOrdersSettings;
     ProductSpecificationsViewService      = productSpecificationsViewService ?? throw new ArgumentNullException(nameof(productSpecificationsViewService));
     MyAccountUrlProvider                  = myAccountUrlProvider ?? throw new ArgumentNullException(nameof(myAccountUrlProvider));
 }
        public async Task WHEN_Passing_Valid_Values_With_One_MediaSet_Variants_Within_Parameter_SHOULD_Succeed()
        {
            _container.Use(_productMediaSettingsRepositoryMock);

            // Arrange
            var          expectedProductId = GetRandom.String(32);
            IDamProvider damProvider       = _container.CreateInstance <ConventionBasedDamProvider>();

            var ImageSize            = GetRandom.String(1);
            var ThumbnailImageSize   = GetRandom.String(1);
            var ProductZoomImageSize = GetRandom.String(1);
            var PropertyBag          = new Overture.ServiceModel.PropertyBag()
            {
                { GetRandom.String(5), GetRandom.String(5) as object }
            };
            var productMedia = GetProductMediaMock(new string[] { ImageSize, ThumbnailImageSize, ProductZoomImageSize });
            var variant1Id   = GetRandom.String(5);
            var variant2Id   = GetRandom.String(5);
            var imageUrl     = productMedia.ResizedInstances.FirstOrDefault(instance => instance.Size == ImageSize).Url.Substring(1);

            var param = new GetAllProductImagesParam()
            {
                ImageSize            = ImageSize,
                ThumbnailImageSize   = ThumbnailImageSize,
                ProductZoomImageSize = ProductZoomImageSize,
                ProductId            = expectedProductId,
                Variants             = new List <Variant>()
                {
                    new Variant
                    {
                        Id          = variant1Id,
                        PropertyBag = PropertyBag
                    },
                    new Variant
                    {
                        Id       = variant2Id,
                        MediaSet = new List <ProductMedia>()
                        {
                            productMedia,
                        }
                    },
                },
            };

            // Act
            var results = await damProvider.GetAllProductImagesAsync(param).ConfigureAwait(false);

            // Assert
            results.Should().NotBeEmpty();
            results.Where(result => string.IsNullOrWhiteSpace(result.ImageUrl)).Should().NotBeNullOrEmpty("Because results should have a unknown default Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.FallbackImageUrl)).Should().BeEmpty("Because all results should have a known fallback Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ThumbnailUrl)).Should().NotBeNullOrEmpty("Because results should have a unknown thumbnail Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ProductZoomImageUrl)).Should().NotBeNullOrEmpty("Because results should have a unknown Product Zoom Image url");
            results.Where(result => result.ProductId != expectedProductId).Should().BeEmpty("Because all results should match the requested product id");
            results.Where(result => result.ProductId == expectedProductId).Should().NotBeNullOrEmpty("Because the product must be found");

            results.FirstOrDefault(result => result.VariantId == null).ImageUrl.Should().Be("");
            results.FirstOrDefault(result => result.VariantId == variant1Id).ImageUrl.Should().Be("");
            results.FirstOrDefault(result => result.VariantId == variant2Id).ImageUrl.Contains(imageUrl).Should().Be(true);
        }
 protected BaseSearchViewService(
     ISearchRepository searchRepository,
     IViewModelMapper viewModelMapper,
     IDamProvider damProvider,
     ILocalizationProvider localizationProvider,
     IProductUrlProvider productUrlProvider,
     ISearchUrlProvider searchUrlProvider,
     IFacetFactory facetFactory,
     ISelectedFacetFactory selectedFacetFactory,
     IPriceProvider priceProvider,
     IComposerContext composerContext,
     IProductSettingsViewService productSettings,
     IScopeViewService scopeViewService,
     IRecurringOrdersSettings recurringOrdersSettings)
 {
     SearchRepository        = searchRepository ?? throw new ArgumentNullException(nameof(searchRepository));
     ViewModelMapper         = viewModelMapper ?? throw new ArgumentNullException(nameof(viewModelMapper));
     DamProvider             = damProvider ?? throw new ArgumentNullException(nameof(damProvider));
     LocalizationProvider    = localizationProvider ?? throw new ArgumentNullException(nameof(localizationProvider));
     ProductUrlProvider      = productUrlProvider ?? throw new ArgumentNullException(nameof(productUrlProvider));
     SearchUrlProvider       = searchUrlProvider ?? throw new ArgumentNullException(nameof(searchUrlProvider));
     SelectedFacetFactory    = selectedFacetFactory ?? throw new ArgumentNullException(nameof(selectedFacetFactory));
     FacetFactory            = facetFactory ?? throw new ArgumentNullException(nameof(facetFactory));
     PriceProvider           = priceProvider ?? throw new ArgumentNullException(nameof(priceProvider));
     ComposerContext         = composerContext ?? throw new ArgumentNullException(nameof(composerContext));
     ProductSettings         = productSettings ?? throw new ArgumentNullException(nameof(productSettings));
     ScopeViewService        = scopeViewService ?? throw new ArgumentNullException(nameof(scopeViewService));
     RecurringOrdersSettings = recurringOrdersSettings ?? throw new ArgumentNullException(nameof(recurringOrdersSettings));
 }
Example #5
0
        public async Task WHEN_KeyVariantAttributeValues_Is_Null_SHOULD_Succeed()
        {
            //Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act
            List <ProductMainImage> images = await damProvider.GetProductMainImagesAsync(new GetProductMainImagesParam
            {
                ImageSize            = GetRandom.String(1),
                ProductImageRequests = new ProductImageRequest[]
                {
                    new ProductImageRequest
                    {
                        ProductId = GetRandom.String(32),
                        Variant   = new VariantKey
                        {
                            Id = GetRandom.String(32)
                        }
                    }
                }.ToList(),
            }).ConfigureAwait(false);

            // Assert
            images.Should().NotBeNull();
        }
Example #6
0
        public CategoryBrowsingViewService(ISearchRepository searchRepository,
                                           IDamProvider damProvider,
                                           ILocalizationProvider localizationProvider,
                                           ISearchUrlProvider searchUrlProvider,
                                           ICategoryRepository categoryRepository,
                                           ICategoryBrowsingUrlProvider categoryBrowsingUrlProvider,
                                           IFacetFactory facetFactory,
                                           ISelectedFacetFactory selectedFacetFactory,
                                           IComposerContext composerContext,
                                           IFulfillmentContext fulfillmentContext,
                                           IProductSearchViewModelFactory productSearchViewModelFactory)

            : base(searchRepository,
                   damProvider,
                   localizationProvider,
                   searchUrlProvider,
                   facetFactory,
                   selectedFacetFactory,
                   composerContext,
                   productSearchViewModelFactory,
                   categoryRepository)

        {
            CategoryRepository          = categoryRepository ?? throw new ArgumentNullException(nameof(categoryRepository));
            CategoryBrowsingUrlProvider = categoryBrowsingUrlProvider ?? throw new ArgumentNullException(nameof(categoryBrowsingUrlProvider));
            FulfillmentContext          = fulfillmentContext ?? throw new ArgumentNullException(nameof(fulfillmentContext));
        }
Example #7
0
            public ProductViewModelFactoryProxy(IViewModelMapper viewModelMapper,
                                                IProductRepository productRepository,
                                                IDamProvider damProvider,
                                                ILocalizationProvider localizationProvider,
                                                ILookupService lookupService,
                                                IProductUrlProvider productUrlProvider,
                                                IScopeViewService scopeViewService,
                                                IRecurringOrdersRepository recurringOrdersRepository,
                                                IRecurringOrderProgramViewModelFactory recurringOrderProgramViewModelFactory,
                                                IRecurringOrdersSettings recurringOrdersSettings,
                                                IProductSpecificationsViewService productSpecificationsViewService)

                : base(
                    viewModelMapper,
                    productRepository,
                    damProvider,
                    localizationProvider,
                    lookupService,
                    productUrlProvider,
                    scopeViewService,
                    recurringOrdersRepository,
                    recurringOrderProgramViewModelFactory,
                    recurringOrdersSettings,
                    productSpecificationsViewService)
            {
            }
Example #8
0
        public CategoryBrowsingViewService(
            ISearchRepository searchRepository,
            IViewModelMapper viewModelMapper,
            IDamProvider damProvider,
            ILocalizationProvider localizationProvider,
            IProductUrlProvider productUrlProvider,
            ISearchUrlProvider searchUrlProvider,
            ICategoryRepository categoryRepository,
            ICategoryBrowsingUrlProvider categoryBrowsingUrlProvider,
            IFacetFactory facetFactory,
            ISelectedFacetFactory selectedFacetFactory,
            IPriceProvider priceProvider,
            IComposerContext composerContext,
            IProductSettingsViewService productSettings,
            IScopeViewService scopeViewService,
            IRecurringOrdersSettings recurringOrdersSettings)

            : base(
                searchRepository,
                viewModelMapper,
                damProvider,
                localizationProvider,
                productUrlProvider,
                searchUrlProvider,
                facetFactory,
                selectedFacetFactory,
                priceProvider,
                composerContext,
                productSettings,
                scopeViewService,
                recurringOrdersSettings)
        {
            CategoryRepository          = categoryRepository ?? throw new ArgumentNullException(nameof(categoryRepository));
            CategoryBrowsingUrlProvider = categoryBrowsingUrlProvider ?? throw new ArgumentNullException(nameof(categoryBrowsingUrlProvider));
        }
        public async Task WHEN_Passing_Valid_Values_With_No_Variants_Within_Parameter_SHOULD_Succeed()
        {
            // Arrange
            var          expectedProductId = GetRandom.String(32);
            IDamProvider damProvider       = _container.CreateInstance <ConventionBasedDamProvider>();
            var          param             = new GetAllProductImagesParam()
            {
                ImageSize            = GetRandom.String(1),
                ThumbnailImageSize   = GetRandom.String(1),
                ProductZoomImageSize = GetRandom.String(1),
                ProductId            = expectedProductId,
                Variants             = null
            };

            // Act
            var results = await damProvider.GetAllProductImagesAsync(param).ConfigureAwait(false);

            // Assert
            results.Should().NotBeEmpty();
            results.ForEach(x => x.VariantId.Should().BeNull("There should be no variants because it was not specified in the request."));
            results.Where(result => string.IsNullOrWhiteSpace(result.ImageUrl)).Should().BeEmpty("Because all results should have a known default Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.FallbackImageUrl)).Should().BeEmpty("Because all results should have a known fallback Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ThumbnailUrl)).Should().BeEmpty("Because all results should have a known thumbnail Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ProductZoomImageUrl)).Should().BeEmpty("Because all results should have a known Product Zoom Image url");
            results.Where(result => result.ProductId != expectedProductId).Should().BeEmpty("Because all results should match the requested product id");
            results.Where(result => result.ProductId == expectedProductId).Should().NotBeNullOrEmpty("Because the product must be found");
        }
Example #10
0
 /// <summary>
 /// CartService constructor
 /// </summary>
 /// <param name="cartRepository">The repository for accessing cart data</param>
 /// <param name="damProvider">The provider for providing images</param>
 /// <param name="cartViewModelFactory">Factory creating a <see cref="CartViewModel"/>.</param>
 /// <param name="couponViewService">The <see cref="ICouponViewService"/>.</param>
 /// <param name="lookupService">The <see cref="ILookupService"/>.</param>
 /// <param name="lineItemService">The <see cref="ILineItemService"/>.</param>
 /// <param name="fixCartService">The <see cref="IFixCartService"/>.</param>
 /// <param name="countryService">The <see cref="ICountryService"/></param>
 /// <param name="regionCodeProvider">The <see cref="IRegionCodeProvider"/></param>
 /// <param name="imageService">The <see cref="IImageService"/></param>
 public CartService(
     ICartRepository cartRepository,
     IDamProvider damProvider,
     ICartViewModelFactory cartViewModelFactory,
     ICouponViewService couponViewService,
     ILookupService lookupService,
     ILineItemService lineItemService,
     IFixCartService fixCartService,
     ICountryService countryService,
     IRegionCodeProvider regionCodeProvider,
     IImageService imageService,
     ICategoryRepository categoryRepository,
     ILocalizationProvider localizationProvider,
     IEditingOrderProvider editingOrderprovider)
 {
     CartRepository       = cartRepository ?? throw new ArgumentNullException(nameof(cartRepository));
     CartViewModelFactory = cartViewModelFactory ?? throw new ArgumentNullException(nameof(cartViewModelFactory));
     CouponViewService    = couponViewService ?? throw new ArgumentNullException(nameof(couponViewService));
     LookupService        = lookupService ?? throw new ArgumentNullException(nameof(lookupService));
     LineItemService      = lineItemService ?? throw new ArgumentNullException(nameof(lineItemService));
     FixCartService       = fixCartService ?? throw new ArgumentNullException(nameof(fixCartService));
     CountryService       = countryService ?? throw new ArgumentNullException(nameof(fixCartService));
     RegionCodeProvider   = regionCodeProvider ?? throw new ArgumentNullException(nameof(regionCodeProvider));
     ImageService         = imageService ?? throw new ArgumentNullException(nameof(imageService));
     LocalizationProvider = localizationProvider ?? throw new ArgumentNullException(nameof(localizationProvider));
     CategoryRepository   = categoryRepository ?? throw new ArgumentNullException(nameof(categoryRepository));
     EditingOrderProvider = editingOrderprovider ?? throw new ArgumentNullException(nameof(editingOrderprovider));
 }
 public SearchQueryViewService(
     ICategoryRepository categoryRepository,
     ISearchRepository searchRepository,
     IDamProvider damProvider,
     ILocalizationProvider localizationProvider,
     ISearchUrlProvider searchUrlProvider,
     IFacetFactory facetFactory,
     ISelectedFacetFactory selectedFacetFactory,
     IComposerContext composerContext,
     ISearchQueryRepository searchQueryRepository,
     ISearchQueryUrlProvider searchQueryUrlProvider,
     IProductSettingsRepository productSettingsRepository,
     Repositories.IInventoryRepository inventoryRepository,
     IProductSearchViewModelFactory productSearchViewModelFactory)
     : base(
         searchRepository,
         damProvider,
         localizationProvider,
         searchUrlProvider,
         facetFactory,
         selectedFacetFactory,
         composerContext,
         productSearchViewModelFactory,
         categoryRepository)
 {
     SearchQueryRepository     = searchQueryRepository ?? throw new ArgumentNullException(nameof(searchQueryRepository));
     SearchQueryUrlProvider    = searchQueryUrlProvider ?? throw new ArgumentNullException(nameof(searchQueryUrlProvider));
     ProductSettingsRepository = productSettingsRepository;
     InventoryRepository       = inventoryRepository;
 }
Example #12
0
        public async Task WHEN_VariantId_Is_NullOrWhiteSpace_SHOULD_Succeed(string variantId)
        {
            //Arrange
            var          expectedProductId = GetRandom.String(32);
            IDamProvider damProvider       = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act
            List <ProductMainImage> images = await damProvider.GetProductMainImagesAsync(new GetProductMainImagesParam
            {
                ImageSize            = GetRandom.String(1),
                ProductImageRequests = new ProductImageRequest[]
                {
                    new ProductImageRequest
                    {
                        ProductId = expectedProductId,
                        Variant   = new VariantKey
                        {
                            Id = variantId
                        }
                    }
                }.ToList(),
            }).ConfigureAwait(false);

            // Assert
            images.Should().NotBeNull("Empty variantID actually means we want the images for the product");
            images.Where(result => string.IsNullOrWhiteSpace(result.ImageUrl)).Should().BeEmpty("Because all results should have a known default Image url");
            images.Where(result => string.IsNullOrWhiteSpace(result.FallbackImageUrl)).Should().BeEmpty("Because all results should have a known fallback Image url");
            images.Where(result => result.ProductId != expectedProductId).Should().BeEmpty("Because all results should match the requested product id");
            images.Where(result => result.ProductId == expectedProductId).Should().NotBeNullOrEmpty("Because the product must be found");
        }
Example #13
0
        public void WHEN_Passing_Null_Parameters_SHOULD_Throw_ArgumentNullException()
        {
            //Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act & Assert
            Assert.ThrowsAsync <ArgumentNullException>(() => damProvider.GetProductMainImagesAsync(null));
        }
 public RelatedProductViewServiceProxy(IProductRepository productRepository,
                                       IRelationshipRepository relationshipRepository,
                                       IDamProvider damProvider, IProductUrlProvider
                                       productUrlProvider, IViewModelMapper viewModelMapper,
                                       ILocalizationProvider localizationProvider,
                                       IInventoryLocationProvider inventoryLocationProvider,
                                       IRecurringOrdersSettings recurringOrdersSettings) : base(productRepository, relationshipRepository, damProvider, productUrlProvider, viewModelMapper, localizationProvider, inventoryLocationProvider, recurringOrdersSettings)
 {
 }
        public void WHEN_Passing_Null_Parameter_SHOULD_Throw_Exception()
        {
            // Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act & Assert
            var exception = Assert.ThrowsAsync <ArgumentNullException>(() => damProvider.GetAllProductImagesAsync(null));

            exception.Message.Should().Be("The method parameter is required.\r\nParameter name: param");
        }
        public void WHEN_Passing_Null_Parameter_SHOULD_Throw_Exception()
        {
            // Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act & Assert
            Expression <Func <Task <List <AllProductImages> > > > expression = () => damProvider.GetAllProductImagesAsync(null);
            var exception = Assert.ThrowsAsync <ArgumentNullException>(() => expression.Compile().Invoke());

            exception.ParamName.Should().BeEquivalentTo(GetParamsInfo(expression)[0].Name);
        }
Example #17
0
        public LineItemService(IDamProvider damProvider, ILineItemValidationProvider lineItemValidationProvider)
        {
            if (damProvider == null)
            {
                throw new ArgumentNullException("damProvider");
            }
            if (lineItemValidationProvider == null)
            {
                throw new ArgumentNullException("lineItemValidationProvider");
            }

            DamProvider = damProvider;
            LineItemValidationProvider = lineItemValidationProvider;
        }
Example #18
0
        public void WHEN_ProductImageInfos_Is_Null_SHOULD_Throw_ArgumentException()
        {
            //Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act & Assert
            Assert.ThrowsAsync <ArgumentException>(() =>
                                                   damProvider.GetProductMainImagesAsync(new GetProductMainImagesParam
            {
                ImageSize            = GetRandom.String(1),
                ProductImageRequests = null,
            })
                                                   );
        }
Example #19
0
        public SearchQueryViewService(
            ISearchRepository searchRepository,
            IViewModelMapper viewModelMapper,
            IDamProvider damProvider,
            ILocalizationProvider localizationProvider,
            IProductUrlProvider productUrlProvider,
            ISearchUrlProvider searchUrlProvider,
            IFacetFactory facetFactory,
            ISelectedFacetFactory selectedFacetFactory,
            IPriceProvider priceProvider,
            IComposerContext composerContext,
            IProductSettingsViewService productSettings,
            IScopeViewService scopeViewService,
            ISearchQueryRepository searchQueryRepository,
            ISearchQueryUrlProvider searchQueryUrlProvider,
            IProductSettingsRepository productSettingsRepository,
            Repositories.IInventoryRepository inventoryRepository,
            IRecurringOrdersSettings recurringOrdersSettings
            )

            : base(
                searchRepository,
                viewModelMapper,
                damProvider,
                localizationProvider,
                productUrlProvider,
                searchUrlProvider,
                facetFactory,
                selectedFacetFactory,
                priceProvider,
                composerContext,
                productSettings,
                scopeViewService,
                recurringOrdersSettings)
        {
            if (searchQueryRepository == null)
            {
                throw new ArgumentNullException("searchQueryRepository");
            }
            if (searchQueryUrlProvider == null)
            {
                throw new ArgumentNullException("searchQuerySearchRepository");
            }

            SearchQueryRepository     = searchQueryRepository;
            SearchQueryUrlProvider    = searchQueryUrlProvider;
            ProductSettingsRepository = productSettingsRepository;
            InventoryRepository       = inventoryRepository;
        }
        public void WHEN_Passing_Null_Or_Empty_ThumbnailImageSize_Within_Parameter_SHOULD_Throw_Exception(string thumbnailImageSize)
        {
            // Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();
            var          param       = new GetAllProductImagesParam()
            {
                ImageSize            = GetRandom.String(1),
                ThumbnailImageSize   = thumbnailImageSize,
                ProductZoomImageSize = GetRandom.String(1),
                ProductId            = GetRandom.String(10)
            };

            // Act & Assert
            var exception = Assert.ThrowsAsync <ArgumentException>(() => damProvider.GetAllProductImagesAsync(param));

            exception.Message.Should().Be("The thumbnail image size is required.");
        }
        public void WHEN_Passing_Null_Or_Empty_ThumbnailImageSize_Within_Parameter_SHOULD_Throw_Exception(string thumbnailImageSize)
        {
            // Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();
            var          param       = new GetAllProductImagesParam()
            {
                ImageSize            = GetRandom.String(1),
                ThumbnailImageSize   = thumbnailImageSize,
                ProductZoomImageSize = GetRandom.String(1),
                ProductId            = GetRandom.String(10)
            };

            // Act & Assert
            Expression <Func <Task <List <AllProductImages> > > > expression = () => damProvider.GetAllProductImagesAsync(param);
            var exception = Assert.ThrowsAsync <ArgumentException>(() => expression.Compile().Invoke());

            exception.ParamName.Should().BeEquivalentTo(GetParamsInfo(expression)[0].Name);
            exception.Message.Should().StartWith(GetMessageOfNullWhiteSpace(nameof(param.ThumbnailImageSize)));
        }
Example #22
0
 protected BaseProductViewService(
     IProductRepository productRepository,
     IDamProvider damProvider,
     IProductUrlProvider productUrlProvider,
     IViewModelMapper viewModelMapper,
     ILocalizationProvider localizationProvider,
     IRelationshipRepository relationshipRepository,
     IInventoryLocationProvider inventoryLocationProvider,
     IRecurringOrdersSettings recurringOrdersSettings)
 {
     ProductRepository         = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
     ViewModelMapper           = viewModelMapper ?? throw new ArgumentNullException(nameof(viewModelMapper));
     DamProvider               = damProvider ?? throw new ArgumentNullException(nameof(damProvider));
     LocalizationProvider      = localizationProvider ?? throw new ArgumentNullException(nameof(localizationProvider));
     ProductUrlProvider        = productUrlProvider ?? throw new ArgumentNullException(nameof(productUrlProvider));
     RelationshipRepository    = relationshipRepository ?? throw new ArgumentNullException(nameof(relationshipRepository));
     InventoryLocationProvider = inventoryLocationProvider ?? throw new ArgumentNullException(nameof(inventoryLocationProvider));
     RecurringOrdersSettings   = recurringOrdersSettings ?? throw new ArgumentNullException(nameof(recurringOrdersSettings));
 }
 protected BaseSearchViewService(ISearchRepository searchRepository,
                                 IDamProvider damProvider,
                                 ILocalizationProvider localizationProvider,
                                 ISearchUrlProvider searchUrlProvider,
                                 IFacetFactory facetFactory,
                                 ISelectedFacetFactory selectedFacetFactory,
                                 IComposerContext composerContext,
                                 IProductSearchViewModelFactory productSearchViewModelFactory,
                                 ICategoryRepository categoryRepository)
 {
     SearchRepository              = searchRepository ?? throw new ArgumentNullException(nameof(searchRepository));
     DamProvider                   = damProvider ?? throw new ArgumentNullException(nameof(damProvider));
     LocalizationProvider          = localizationProvider ?? throw new ArgumentNullException(nameof(localizationProvider));
     SearchUrlProvider             = searchUrlProvider ?? throw new ArgumentNullException(nameof(searchUrlProvider));
     SelectedFacetFactory          = selectedFacetFactory ?? throw new ArgumentNullException(nameof(selectedFacetFactory));
     FacetFactory                  = facetFactory ?? throw new ArgumentNullException(nameof(facetFactory));
     ComposerContext               = composerContext ?? throw new ArgumentNullException(nameof(composerContext));
     ProductSearchViewModelFactory = productSearchViewModelFactory ?? throw new ArgumentNullException(nameof(productSearchViewModelFactory));
     CategoryRepository            = categoryRepository ?? throw new ArgumentNullException(nameof(categoryRepository));
 }
Example #24
0
 public SearchViewService(
     ICategoryRepository categoryRepository,
     ISearchRepository searchRepository,
     IDamProvider damProvider,
     ILocalizationProvider localizationProvider,
     ISearchUrlProvider searchUrlProvider,
     IFacetFactory facetFactory,
     ISelectedFacetFactory selectedFacetFactory,
     IComposerContext composerContext,
     IProductSearchViewModelFactory productSearchViewModelFactory)
     : base(
         searchRepository,
         damProvider,
         localizationProvider,
         searchUrlProvider,
         facetFactory,
         selectedFacetFactory,
         composerContext,
         productSearchViewModelFactory,
         categoryRepository)
 {
 }
Example #25
0
        public CategoryBrowsingViewService2(ISearchRepository searchRepository,
                                            IViewModelMapper viewModelMapper,
                                            IDamProvider damProvider,
                                            ILocalizationProvider localizationProvider,
                                            IProductUrlProvider productUrlProvider,
                                            ISearchUrlProvider searchUrlProvider,
                                            IComposerContext context,
                                            ICategoryRepository categoryRepository,
                                            ICategoryBrowsingUrlProvider categoryBrowsingUrlProvider) : base(searchRepository, viewModelMapper, damProvider, localizationProvider, productUrlProvider, searchUrlProvider)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (categoryRepository == null)
            {
                throw new ArgumentNullException("categoryRepository");
            }

            _context                     = context;
            _categoryRepository          = categoryRepository;
            _categoryBrowsingUrlProvider = categoryBrowsingUrlProvider;
        }
Example #26
0
        public void WHEN_ImageSize_Is_NullOrWhiteSpace_SHOULD_Throw_ArgumentException(string imageSize)
        {
            //Arrange
            IDamProvider damProvider = _container.CreateInstance <ConventionBasedDamProvider>();

            // Act & Assert
            Assert.ThrowsAsync <ArgumentException>(() =>
                                                   damProvider.GetProductMainImagesAsync(new GetProductMainImagesParam
            {
                ImageSize            = imageSize,
                ProductImageRequests = new ProductImageRequest[]
                {
                    new ProductImageRequest
                    {
                        ProductId = GetRandom.String(32),
                        Variant   = new VariantKey
                        {
                            Id = GetRandom.String(32)
                        }
                    }
                }.ToList(),
            })
                                                   );
        }
        public async Task WHEN_Passing_Valid_Values_With_Variants_Within_Parameter_SHOULD_Succeed()
        {
            // Arrange
            var          expectedProductId = GetRandom.String(32);
            IDamProvider damProvider       = _container.CreateInstance <ConventionBasedDamProvider>();
            var          variantId1        = GetRandom.String(5);
            var          variantId2        = GetRandom.String(5);
            var          variantId3        = GetRandom.String(5);

            // Act
            var results = await damProvider.GetAllProductImagesAsync(new GetAllProductImagesParam()
            {
                ImageSize            = GetRandom.String(1),
                ThumbnailImageSize   = GetRandom.String(1),
                ProductZoomImageSize = GetRandom.String(1),
                ProductId            = expectedProductId,
                Variants             = new List <Variant>()
                {
                    new Variant
                    {
                        Id = variantId1,
                    },
                    new Variant
                    {
                        Id = variantId2,
                    },
                    new Variant
                    {
                        Id = variantId3,
                    }
                }
            }).ConfigureAwait(false);

            // Assert
            results.Should().NotBeNull();
            int index = 0;

            results.ForEach(x =>
            {
                if (index % ConventionBasedDamProviderConfiguration.MaxThumbnailImages == 0)
                {
                    x.VariantId.Should().BeNull("This is a main image for a product only.");
                }
                else if (index % ConventionBasedDamProviderConfiguration.MaxThumbnailImages == 1)
                {
                    x.VariantId.Should().Be(variantId1);
                }
                else if (index % ConventionBasedDamProviderConfiguration.MaxThumbnailImages == 2)
                {
                    x.VariantId.Should().Be(variantId2);
                }
                else if (index % ConventionBasedDamProviderConfiguration.MaxThumbnailImages == 3)
                {
                    x.VariantId.Should().Be(variantId3);
                }

                index++;
            });

            results.Should().NotBeEmpty();
            results.Where(result => string.IsNullOrWhiteSpace(result.ImageUrl)).Should().BeEmpty("Because all results should have a known default Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.FallbackImageUrl)).Should().BeEmpty("Because all results should have a known fallback Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ThumbnailUrl)).Should().BeEmpty("Because all results should have a known thumbnail Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ProductZoomImageUrl)).Should().BeEmpty("Because all results should have a known Product Zoom Image url");
            results.Where(result => result.ProductId != expectedProductId).Should().BeEmpty("Because all results should match the requested product id");
            results.Where(result => result.ProductId == expectedProductId).Should().NotBeNullOrEmpty("Because the product must be found");
        }
        public async Task WHEN_Passing_Valid_Values_With_MediaSet_Variants_Within_Parameter_SHOULD_Succeed()
        {
            _container.Use(_productMediaSettingsRepositoryMock);

            // Arrange
            var          expectedProductId = GetRandom.String(32);
            IDamProvider damProvider       = _container.CreateInstance <ConventionBasedDamProvider>();

            var ImageSize            = GetRandom.String(1);
            var ThumbnailImageSize   = GetRandom.String(1);
            var ProductZoomImageSize = GetRandom.String(1);
            var PropertyBag          = new Overture.ServiceModel.PropertyBag()
            {
                { GetRandom.String(5), GetRandom.String(5) as object }
            };

            var param = new GetAllProductImagesParam()
            {
                ImageSize            = ImageSize,
                ThumbnailImageSize   = ThumbnailImageSize,
                ProductZoomImageSize = ProductZoomImageSize,
                ProductId            = expectedProductId,
                Variants             = new List <Variant>()
                {
                    new Variant
                    {
                        Id          = GetRandom.String(5),
                        PropertyBag = PropertyBag
                    },
                    new Variant
                    {
                        Id       = GetRandom.String(5),
                        MediaSet = new List <ProductMedia>()
                        {
                            GetProductMediaMock(new string[] { ImageSize, ThumbnailImageSize, ProductZoomImageSize }),
                        }
                    },
                },
                MediaSet = new List <ProductMedia>()
                {
                    GetProductMediaMock(new string[] { ImageSize, ThumbnailImageSize, ProductZoomImageSize })
                },
                VariantMediaSet = new List <VariantMediaSet>()
                {
                    new VariantMediaSet()
                    {
                        Media = new ProductMedia[]
                        {
                            GetProductMediaMock(new string[] { ImageSize, ThumbnailImageSize, ProductZoomImageSize }),
                        },
                        AttributesToMatch = PropertyBag
                    }
                }
            };

            // Act
            var results = await damProvider.GetAllProductImagesAsync(param).ConfigureAwait(false);

            // Assert
            results.Should().NotBeEmpty();
            results.Where(result => string.IsNullOrWhiteSpace(result.ImageUrl)).Should().BeEmpty("Because all results should have a known default Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.FallbackImageUrl)).Should().BeEmpty("Because all results should have a known fallback Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ThumbnailUrl)).Should().BeEmpty("Because all results should have a known thumbnail Image url");
            results.Where(result => string.IsNullOrWhiteSpace(result.ProductZoomImageUrl)).Should().BeEmpty("Because all results should have a known Product Zoom Image url");
            results.Where(result => result.ProductId != expectedProductId).Should().BeEmpty("Because all results should match the requested product id");
            results.Where(result => result.ProductId == expectedProductId).Should().NotBeNullOrEmpty("Because the product must be found");
            results.Where(result => results.Where(x => x.ImageUrl == result.ImageUrl).ToList().Count > 1).Should().BeEmpty("Because all results should have unique ImageUrl");
        }
Example #29
0
 public ImageService(IDamProvider damProvider, IProductRepository productRepository, IComposerContext composerContext)
 {
     DamProvider       = damProvider ?? throw new ArgumentNullException(nameof(damProvider));
     ProductRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
     ComposerContext   = composerContext ?? throw new ArgumentNullException("composerContext");
 }
Example #30
0
        /// <summary>
        /// CartService constructor
        /// </summary>
        /// <param name="cartRepository">The repository for accessing cart data</param>
        /// <param name="damProvider">The provider for providing images</param>
        /// <param name="cartViewModelFactory">Factory creating a <see cref="CartViewModel"/>.</param>
        /// <param name="couponViewService">The <see cref="ICouponViewService"/>.</param>
        /// <param name="lookupService">The <see cref="ILookupService"/>.</param>
        /// <param name="lineItemService">The <see cref="ILineItemService"/>.</param>
        /// <param name="fixCartService">The <see cref="IFixCartService"/>.</param>
        /// <param name="countryService">The <see cref="ICountryService"/></param>
        /// <param name="regionCodeProvider">The <see cref="IRegionCodeProvider"/></param>
        /// <param name="imageService">The <see cref="IImageService"/></param>
        public CartService(
            ICartRepository cartRepository,
            IDamProvider damProvider,
            ICartViewModelFactory cartViewModelFactory,
            ICouponViewService couponViewService,
            ILookupService lookupService,
            ILineItemService lineItemService,
            IFixCartService fixCartService,
            ICountryService countryService,
            IRegionCodeProvider regionCodeProvider,
            IImageService imageService)
        {
            if (cartRepository == null)
            {
                throw new ArgumentNullException("cartRepository");
            }
            if (damProvider == null)
            {
                throw new ArgumentNullException("damProvider");
            }
            if (cartViewModelFactory == null)
            {
                throw new ArgumentNullException("cartViewModelFactory");
            }
            if (couponViewService == null)
            {
                throw new ArgumentNullException("couponViewService");
            }
            if (lookupService == null)
            {
                throw new ArgumentNullException("lookupService");
            }
            if (lineItemService == null)
            {
                throw new ArgumentNullException("lineItemService");
            }
            if (fixCartService == null)
            {
                throw new ArgumentNullException("fixCartService");
            }
            if (countryService == null)
            {
                throw new ArgumentNullException("fixCartService");
            }
            if (regionCodeProvider == null)
            {
                throw new ArgumentNullException("regionCodeProvider");
            }
            if (imageService == null)
            {
                throw new ArgumentNullException("imageService");
            }

            CartRepository       = cartRepository;
            CartViewModelFactory = cartViewModelFactory;
            CouponViewService    = couponViewService;
            LookupService        = lookupService;
            LineItemService      = lineItemService;
            FixCartService       = fixCartService;
            CountryService       = countryService;
            RegionCodeProvider   = regionCodeProvider;
            ImageService         = imageService;
        }