コード例 #1
0
        public void YieldCartLines_04_NoLineItemComponent(
            IRuleValue <string> targetBrand,
            Cart cart,
            CommerceContext commerceContext,
            IRuleExecutionContext context)
        {
            /**********************************************
            * Arrange
            **********************************************/
            context.Fact <CommerceContext>().ReturnsForAnyArgs(commerceContext);
            commerceContext.AddObject(cart);
            targetBrand.Yield(context).ReturnsForAnyArgs("Smartphone");

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

            /**********************************************
            * Assert
            **********************************************/
            executeAction.Should().NotThrow <Exception>();
            matchingLines.Should().BeEmpty();
        }
コード例 #2
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);
        }