Ejemplo n.º 1
0
        public void Index_WhenCampaignHasTwoPromotions_ShouldCreateModelsForBothPromotions()
        {
            var controller = CreateController();

            var firstPromotion = new SpendAmountGetShippingDiscount()
            {
                Name = "The first promotion", IsActive = true
            };
            var secondPromotion = new SpendAmountGetShippingDiscount()
            {
                Name = "The second promotion", IsActive = true
            };
            var catalogItemSelectionMock = new Mock <CatalogItemSelection>(null, null, null);

            _marketContentLoaderMock.Setup(x => x.GetPromotionItemsForMarket(It.IsAny <IMarket>()))
            .Returns(new PromotionItems[] {
                new PromotionItems(firstPromotion, catalogItemSelectionMock.Object, catalogItemSelectionMock.Object),
                new PromotionItems(secondPromotion, catalogItemSelectionMock.Object, catalogItemSelectionMock.Object)
            });

            var result = controller.Index(new StartPage());

            Assert.Equal(firstPromotion.Name, ((StartPageViewModel)result.Model).Promotions.First().Name);
            Assert.Equal(secondPromotion.Name, ((StartPageViewModel)result.Model).Promotions.Last().Name);
        }
Ejemplo n.º 2
0
        public void Index_WhenCampaignHasTwoPromotions_ShouldCreateModelsForBothPromotions()
        {
            var controller = CreateController();

            var firstPromotion = new SpendAmountGetShippingDiscount() { Name = "The first promotion", IsActive = true };
            var secondPromotion = new SpendAmountGetShippingDiscount() { Name = "The second promotion", IsActive = true };
            var catalogItemSelectionMock = new Mock<CatalogItemSelection>(null, null, null);

            _marketContentLoaderMock.Setup(x => x.GetPromotionItemsForMarket(It.IsAny<IMarket>()))
                .Returns(new PromotionItems[] {
                    new PromotionItems(firstPromotion, catalogItemSelectionMock.Object, catalogItemSelectionMock.Object),
                    new PromotionItems(secondPromotion, catalogItemSelectionMock.Object, catalogItemSelectionMock.Object) });

            var result = controller.Index(new StartPage());

            Assert.Equal(firstPromotion.Name, ((StartPageViewModel)result.Model).Promotions.First().Name);
            Assert.Equal(secondPromotion.Name, ((StartPageViewModel)result.Model).Promotions.Last().Name);
        }