Ejemplo n.º 1
0
        public void YieldCartLines_08_Multiple(
            IRuleValue <string> targetBrand,
            Cart cart,
            LineItemProductExtendedComponent component,
            CommerceContext commerceContext,
            IRuleExecutionContext context)
        {
            /**********************************************
            * Arrange
            **********************************************/
            context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
            component.Brand = "Smartphone";
            cart.Lines.ForEach(l => l.SetComponent(component));
            commerceContext.AddObject(cart);
            targetBrand.Yield(context).ReturnsForAnyArgs("Smartphone");

            /**********************************************
            * Act
            **********************************************/
            var matchingLines = targetBrand.YieldCartLinesWithBrand(context);

            /**********************************************
            * Assert
            **********************************************/
            matchingLines.Should().HaveCount(3);
        }
Ejemplo n.º 2
0
        public void YieldCartLines_08_Multiple(
            IRuleValue <string> targetCategorySitecoreId,
            Cart cart,
            LineItemProductExtendedComponent component,
            CommerceContext commerceContext,
            IRuleExecutionContext context)
        {
            /**********************************************
            * Arrange
            **********************************************/
            context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
            component.ParentCategoryList = "8e456d84-4251-dba1-4b86-ce103dedcd02|c2bfaf91-7825-4846-0ad3-0479cdf7b607";
            cart.Lines.ForEach(l => l.SetComponent(component));
            commerceContext.AddObject(cart);
            targetCategorySitecoreId.Yield(context).ReturnsForAnyArgs("c2bfaf91-7825-4846-0ad3-0479cdf7b607");

            /**********************************************
            * Act
            **********************************************/
            var matchingLines = targetCategorySitecoreId.YieldCartLinesWithCategory(context);

            /**********************************************
            * Assert
            **********************************************/
            matchingLines.Should().HaveCount(3);
        }
Ejemplo n.º 3
0
        public void YieldCartLines_06_EmptyTargetBrand(
            IRuleValue <string> targetBrand,
            Cart cart,
            LineItemProductExtendedComponent component,
            CommerceContext commerceContext,
            IRuleExecutionContext context)
        {
            /**********************************************
            * Arrange
            **********************************************/
            context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
            component.Brand = "Smartphone";
            cart.Lines[1].SetComponent(component);
            commerceContext.AddObject(cart);
            targetBrand.Yield(context).ReturnsForAnyArgs("");

            /**********************************************
            * Act
            **********************************************/
            IEnumerable <CartLineComponent> matchingLines = null;
            Action executeAction = () => matchingLines = targetBrand.YieldCartLinesWithBrand(context);

            /**********************************************
            * Assert
            **********************************************/
            executeAction.Should().NotThrow <Exception>();
            matchingLines.Should().BeEmpty();
        }
Ejemplo n.º 4
0
        public void YieldCartLines_06_EmptyCategory(
            IRuleValue <string> targetCategorySitecoreId,
            Cart cart,
            LineItemProductExtendedComponent component,
            CommerceContext commerceContext,
            IRuleExecutionContext context)
        {
            /**********************************************
            * Arrange
            **********************************************/
            context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
            component.ParentCategoryList = "8e456d84-4251-dba1-4b86-ce103dedcd02|c2bfaf91-7825-4846-0ad3-0479cdf7b607";
            cart.Lines[1].SetComponent(component);
            commerceContext.AddObject(cart);
            targetCategorySitecoreId.Yield(context).ReturnsForAnyArgs("");

            /**********************************************
            * Act
            **********************************************/
            IEnumerable <CartLineComponent> matchingLines = null;
            Action executeAction = () => matchingLines = targetCategorySitecoreId.YieldCartLinesWithCategory(context);

            /**********************************************
            * Assert
            **********************************************/
            executeAction.Should().NotThrow <Exception>();
            matchingLines.Should().BeEmpty();
        }