Exemple #1
0
            public async void Run_ValidFreeGiftAutoRemoveComponent_ShouldRemoveCartLine(
                string promotionId,
                Cart cart,
                FreeGiftAutoRemoveComponent freeGiftAutoRemoveComponent,
                [Frozen] IServiceProvider serviceProvider)
            {
                /**********************************************
                * Arrange
                **********************************************/
                var commercePipelineContext = CreateCommercePipelineExecutionContext();

                var cartLineToBeRemoved = cart.Lines.FirstOrDefault();

                cartLineToBeRemoved.UnitListPrice.Amount = 0;
                cartLineToBeRemoved.Adjustments.FirstOrDefault().AwardingBlock = promotionId;
                cartLineToBeRemoved.SetComponent(freeGiftAutoRemoveComponent);
                freeGiftAutoRemoveComponent.PromotionId = promotionId;

                var removeCartPipeline = Substitute.For <IRemoveCartLinePipeline>();
                var commerceCommander  = Substitute.For <CommerceCommander>(serviceProvider);

                commerceCommander.Pipeline <IRemoveCartLinePipeline>().ReturnsForAnyArgs(removeCartPipeline);

                var sut = new AutoRemoveFreeGiftBlock(commerceCommander);

                /**********************************************
                * Act
                **********************************************/
                await sut.Run(cart, commercePipelineContext);

                /**********************************************
                * Assert
                **********************************************/
                await removeCartPipeline.ReceivedWithAnyArgs().Run(new CartLineArgument(cart, cartLineToBeRemoved), commercePipelineContext);
            }
Exemple #2
0
            public async void Run_NoAutoRemoveFreeGiftBlock_ShouldReturn(
                Cart cart,
                AutoRemoveFreeGiftBlock sut)
            {
                /**********************************************
                * Arrange
                **********************************************/
                var commercePipelineContext = CreateCommercePipelineExecutionContext();

                /**********************************************
                * Act
                **********************************************/
                var result = await sut.Run(cart, commercePipelineContext);

                /**********************************************
                * Assert
                **********************************************/
                result.Should().NotBeNull();
            }
Exemple #3
0
            public async void Run_NullCart_ShouldThrowArgumentNullException(
                AutoRemoveFreeGiftBlock sut)
            {
                /**********************************************
                * Arrange
                **********************************************/
                var commercePipelineContext = CreateCommercePipelineExecutionContext();

                /**********************************************
                * Act
                **********************************************/
                var exception = await Record.ExceptionAsync(() => sut.Run(null, commercePipelineContext));

                /**********************************************
                * Assert
                **********************************************/
                exception.Should().NotBe(null);
                exception.Should().BeOfType <ArgumentNullException>();
            }