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