public void Setup()
        {
            _cheapPriceUSD = new Money(1000, "USD");
            _expensivePriceGBP = new Money(2000, "GBP");
            _discountPriceUSD = new Money(500, "USD");
            _discountPriceGBP = new Money(500, "GBP");
            var catalogSystemMock = new Mock<ICatalogSystem>();
            _promotionServiceMock = new Mock<IPromotionService>();
            _contentLoaderMock = new Mock<IContentLoader>();
            _priceServiceMock = new Mock<IPriceService>();
            _relationRepositoryMock = new Mock<IRelationRepository>();
            _promotionServiceMock = new Mock<IPromotionService>();
            _fakeAppContext = new FakeAppContext();
            _referenceConverterMock = new Mock<ReferenceConverter>(catalogSystemMock.Object)
            {
                CallBase = true
            };

            _urlResolverMock = new Mock<UrlResolver>();
            _assetUrlConventionsMock = new Mock<AssetUrlConventions>();

            _assetUrlResolverMock = new Mock<AssetUrlResolver>(_urlResolverMock.Object,
                _assetUrlConventionsMock.Object,
                _contentLoaderMock.Object);

            _subject = new CatalogIndexer(catalogSystemMock.Object,
                _priceServiceMock.Object,
                new Mock<IInventoryService>().Object,
                new MetaDataContext(),
                _contentLoaderMock.Object,
                _promotionServiceMock.Object,
                _referenceConverterMock.Object,
                _assetUrlResolverMock.Object,
                _relationRepositoryMock.Object,
                _fakeAppContext,
                new Mock<ILogger>().Object);
            var productReference = GetContentReference(444, CatalogContentType.CatalogEntry);
            var greenVariantReference = GetContentReference(445, CatalogContentType.CatalogEntry);
            var bluevariantReference = GetContentReference(446, CatalogContentType.CatalogEntry);
            var rootNodeReference = GetContentReference(10, CatalogContentType.CatalogNode);
            var catalogReference = GetContentReference(4, CatalogContentType.Catalog);
            var variants = new[] { bluevariantReference, greenVariantReference };
            var greenCatalogKey = new CatalogKey(_fakeAppContext.ApplicationId, "Variant 1");
            var blueCatalogKey = new CatalogKey(_fakeAppContext.ApplicationId, "Variant 2");

            SetupGetContentLink("code", productReference);
            SetupGetFashionProduct(productReference, rootNodeReference);
            SetupGetVariants(productReference, variants);
            SetupGetRootNode(rootNodeReference, catalogReference);
            SetupGetCatalog(catalogReference);

            SetupGetDiscountPrice(blueCatalogKey, MarketId.Default, _discountPriceGBP);
            SetupGetDiscountPrice(blueCatalogKey, MarketId.Default, _discountPriceUSD);
            SetupGetDiscountPrice(greenCatalogKey, MarketId.Default, _discountPriceGBP);
            SetupGetDiscountPrice(greenCatalogKey, MarketId.Default, _discountPriceUSD);

            SetupGetItems(variants, CultureInfo.GetCultureInfo("en"), new List<FashionVariant>
            {
                new FashionVariant
                {
                    Code = "Variant 1",
                    Color = "Green",
                },
                new FashionVariant
                {
                    Code = "Variant 2",
                    Color = "Blue",
                }
            });

            SetupGetCatalogEntryPrices(new[]
            {
                greenCatalogKey,
                blueCatalogKey
            });
        }
        public void Setup()
        {
            _appContext = new FakeAppContext();

            SetupContent();
            SetupPricing();
            SetupMarkets();
            SetupReferenceConverter();
            SetupPromotionEntryService();
            
            _subject = new PromotionService(
                _pricingServiceMock.Object,
                _marketServiceMock.Object,
                _contentLoaderMock.Object,
                _referenceConverterMock.Object,
                new FakePromotionHelper(), 
                _promotionEntryServiceMock.Object);
        }
        public void Setup()
        {
            var synchronizedObjectInstanceCache = new Mock<ISynchronizedObjectInstanceCache>();

            _cheapPriceUSD = new Money(1000, "USD");
            _expensivePriceGBP = new Money(2000, "GBP");
            _discountPriceUSD = new Money(500, "USD");
            _discountPriceGBP = new Money(500, "GBP");
            var catalogSystemMock = new Mock<ICatalogSystem>();
            _promotionServiceMock = new Mock<IPromotionService>();
            _contentLoaderMock = new Mock<IContentLoader>();
            _priceServiceMock = new Mock<IPriceService>();
            _relationRepositoryMock = new Mock<IRelationRepository>();
            _promotionServiceMock = new Mock<IPromotionService>();
            _fakeAppContext = new FakeAppContext();
            _referenceConverterMock = new Mock<ReferenceConverter>(
                new EntryIdentityResolver(synchronizedObjectInstanceCache.Object),
                new NodeIdentityResolver(synchronizedObjectInstanceCache.Object))
            {
                CallBase = true
            };

            _urlResolverMock = new Mock<UrlResolver>();
            _assetUrlConventionsMock = new Mock<AssetUrlConventions>();

            _assetUrlResolverMock = new Mock<AssetUrlResolver>(_urlResolverMock.Object,
                _assetUrlConventionsMock.Object,
                _contentLoaderMock.Object);

            _subject = new SearchDocumentController(_priceServiceMock.Object,
                _promotionServiceMock.Object,
                _contentLoaderMock.Object,
                _referenceConverterMock.Object,
                _assetUrlResolverMock.Object,
                _relationRepositoryMock.Object,
                _fakeAppContext)
            {
                Request = new HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };

            var productReference = GetContentReference(444, CatalogContentType.CatalogEntry);
            var greenVariantReference = GetContentReference(445, CatalogContentType.CatalogEntry);
            var bluevariantReference = GetContentReference(446, CatalogContentType.CatalogEntry);
            var rootNodeReference = GetContentReference(10, CatalogContentType.CatalogNode);
            var catalogReference = GetContentReference(4, CatalogContentType.Catalog);
            var variants = new[] { bluevariantReference, greenVariantReference };
            var greenCatalogKey = new CatalogKey(_fakeAppContext.ApplicationId, "Variant 1");
            var blueCatalogKey = new CatalogKey(_fakeAppContext.ApplicationId, "Variant 2");

            SetupGetContentLink("Product", productReference);
            SetupGetFashionProduct(productReference, rootNodeReference);
            SetupGetVariants(productReference, variants);
            SetupGetRootNode(rootNodeReference, catalogReference);
            SetupGetCatalog(catalogReference);

            SetupGetDiscountPrice(blueCatalogKey, MarketId.Default, _discountPriceGBP);
            SetupGetDiscountPrice(blueCatalogKey, MarketId.Default, _discountPriceUSD);
            SetupGetDiscountPrice(greenCatalogKey, MarketId.Default, _discountPriceGBP);
            SetupGetDiscountPrice(greenCatalogKey, MarketId.Default, _discountPriceUSD);

            SetupGetItems(variants, CultureInfo.GetCultureInfo("en"), new List<FashionVariant>
            {
                new FashionVariant
                {
                    Code = "Variant 1",
                    Color = "Green",
                    Size = "Small"
                },
                new FashionVariant
                {
                    Code = "Variant 2",
                    Color = "Blue",
                }
            });

            SetupGetCatalogEntryPrices(new[] 
            { 
                greenCatalogKey, 
                blueCatalogKey
            });
        }
        public PromotionServiceTests()
        {
            _appContext = new FakeAppContext();

            SetupContent();
            SetupPricing();
            SetupMarkets();
            SetupReferenceConverter();
            SetupPromotionEngine();
            _lineItemcalculatorMock = new Mock<ILineItemCalculator>();
            SetupDiscountedPrice();
            
            _subject = new PromotionService(
                _pricingServiceMock.Object,
                _marketServiceMock.Object,
                _contentLoaderMock.Object,
                _referenceConverterMock.Object,
                _lineItemcalculatorMock.Object,
                _promotionEngineMock.Object
                );
        }