Exemple #1
0
        public async Task Run_UpdateIsGiftBoxToTrueForValidItem_ShouldReturnCartLineWithIsGiftBoxEqualTrue()
        {
            var inputCart  = new Cart();
            var cartLineId = Guid.NewGuid().ToString();
            var cartLine   = new CartLineComponent()
            {
                Id       = cartLineId,
                ItemId   = TestSellableItemId,
                Quantity = 1
            };

            cartLine.SetComponent(new CartLineGiftBoxComponent()
            {
                IsGiftBox = false
            });
            inputCart.Lines.Add(cartLine);
            var cartLineGiftBoxArgument      = new CartLineGiftBoxArgument(inputCart, cartLineId, true);
            var sellableItemValidForGiftWrap = new SellableItem();

            sellableItemValidForGiftWrap.AddComponent(null, new SellableItemGiftBoxComponent()
            {
                AllowGiftBox = true
            });
            _getSellableItemPipelineMock
            .Setup(p => p.Run(It.IsAny <ProductArgument>(), It.IsAny <CommercePipelineExecutionContext>()))
            .Returns(Task.FromResult(sellableItemValidForGiftWrap));

            var outputCart = await _pipelineBlock.Run(cartLineGiftBoxArgument, _pipelineContextFake);

            var cartLineGiftBoxComponent = outputCart.Lines
                                           .SingleOrDefault(l => l.Id == cartLineId)
                                           .GetComponent <CartLineGiftBoxComponent>();

            Assert.True(cartLineGiftBoxComponent.IsGiftBox);
        }