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(); }
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); }