public async void Run_ExclusiveCouponAndAutomaticPromotion( Cart cart, CartCouponsComponent coupons, CartCoupon coupon1, CartCoupon coupon2, Promotion promotion1, Promotion promotion2, Promotion promotion3, Promotion promotion4, CouponRequiredPolicy policy, ExclusivePromotionPolicy exclusive, FilterPromotionsWithCouponsByExclusivityBlock block) { /********************************************** * Arrange **********************************************/ this._context.CommerceContext.AddUniqueObjectByType(new EvaluatePromotionsArgument(cart)); coupon1.AddedDate = DateTimeOffset.UtcNow; coupon1.Promotion = new EntityReference { EntityTarget = promotion1.Id }; coupons.List.Clear(); coupons.List.AddRange(new List <CartCoupon> { coupon1, coupon2 }); cart.Components.Add(coupons); promotion1.ValidFrom = DateTimeOffset.UtcNow.AddMinutes(-5); promotion1.Policies.Add(policy); promotion1.Policies.Add(exclusive); promotion2.ValidFrom = DateTimeOffset.UtcNow.AddMinutes(-1); promotion2.Policies.Add(exclusive); promotion3.ValidFrom = DateTimeOffset.UtcNow; promotion3.Policies.Add(exclusive); var promotions = new List <Promotion> { promotion1, promotion2, promotion3, promotion4 }; /********************************************** * Act **********************************************/ var result = await block.Run(promotions, this._context); /********************************************** * Assert **********************************************/ result.Should().NotBeNull(); result.Should().NotBeEmpty(); var expectedPromotions = new List <Promotion> { promotion2, promotion3 }; result.Should().Contain(expectedPromotions); var unexpectedPromotions = new List <Promotion> { promotion1, promotion4 }; result.Should().NotContain(unexpectedPromotions); this._context.CommerceContext.AnyMessage(m => m.Code.Equals(this._context.GetPolicy <KnownResultCodes>().Warning)).Should().BeFalse(); }
public async void Run_NoCart(List <Promotion> promotions, FilterPromotionsWithCouponsByExclusivityBlock block) { /********************************************** * Arrange **********************************************/ /********************************************** * Act **********************************************/ var result = await block.Run(promotions, this._context); /********************************************** * Assert **********************************************/ result.Should().NotBeNull(); result.Should().NotBeEmpty(); this._context.CommerceContext.AnyMessage(m => m.Code.Equals(this._context.GetPolicy <KnownResultCodes>().Warning)).Should().BeFalse(); }
public async void Run_NoCartCoupons(List <Promotion> promotions, Cart cart, FilterPromotionsWithCouponsByExclusivityBlock block) { /********************************************** * Arrange **********************************************/ this._context.CommerceContext.AddUniqueObjectByType(new EvaluatePromotionsArgument(cart)); cart.Components.Clear(); /********************************************** * Act **********************************************/ var result = await block.Run(promotions, this._context); /********************************************** * Assert **********************************************/ result.Should().NotBeNull(); result.Should().NotBeEmpty(); result.Should().Contain(promotions); this._context.CommerceContext.AnyMessage(m => m.Code.Equals(this._context.GetPolicy <KnownResultCodes>().Warning)).Should().BeFalse(); }