public void NoPromotionOfferApply()
        {
            var _controller      = new PromotionEngineController();
            var selectedProducts = NoPromotionOfferData();
            var result           = _controller.ApplyPromotionOffer(selectedProducts);

            Assert.Equal(100, result);
        }
        public void MultiComboProductPromotionApply()
        {
            var _controller      = new PromotionEngineController();
            var selectedProducts = MultiComboProductPromotionData();
            var result           = _controller.ApplyPromotionOffer(selectedProducts);

            Assert.Equal(310, result);
        }
示例#3
0
 public PromotionEngineControllerTests()
 {
     _checkout   = new Mock <ICheckout>();
     _sut        = new PromotionEngineController(_productRepo.Object, _checkout.Object, renderer.Object);
     _productIds = new[] { _product1.Id, _product2.Id };
     _productRepo.Setup(x => x.Get(_product1.Id)).Returns(_product1);
     _productRepo.Setup(x => x.Get(_product2.Id)).Returns(_product2);
     _checkout.Setup(x => x.Total()).Returns(_checkoutTotal);
 }
        public void Init()
        {
            this._mockPromoService = new Mock <IPromotionDataService>();

            this._mockPromoService.Setup(c => c.GetActiveCurrentOffers()).Returns(It.IsAny <List <SKUOfferDetails> >());
            this._mockPromoService.Setup(c => c.AddToCart(It.IsAny <List <PurchaseDetail> >())).Returns(It.IsAny <FinalCart>());
            this._mockPromoService.Setup(c => c.AddIndividualOffer(It.IsAny <IndividualSKUOffer>()));
            this._mockPromoService.Setup(c => c.AddComboOffer(It.IsAny <ComboOffer>()));
            this._mockPromoService.Setup(c => c.ApplyComboOffer(It.IsAny <SKUComboRelation>()));
            this._mockPromoService.Setup(c => c.ApplyIndividualOffer(It.IsAny <SKUIndividualOfferRelation>()));

            this._promoController = new PromotionEngineController(this._mockPromoService.Object);
        }
        public void ApplyPromo()
        {
            var mock = new Mock <IPromotionService>();
            var promotionController = new PromotionEngineController(mock.Object);
            var skuType             = new List <string> {
                "A", "A", "B", "B", "c"
            };
            var result = promotionController.ApplyPromotion(skuType);

            var okResult = result as OkObjectResult;

            // assert
            Assert.IsNotNull(okResult);
            Assert.AreEqual(200, okResult.StatusCode);
        }
        public void checkContoller()
        {
            //Arrange
            SkuIdsDto request = new SkuIdsDto
            {
                ItemA = 1,
                ItemB = 2,
                ItemC = 3,
                ItemD = 4
            };

            Response response = new Response()
            {
                TotalAmount      = 200,
                ResponseMetaData = new ResponseMetaDto()
                {
                    Status = "S"
                }
            };

            var moc = new Mock <IPromotionBO>();

            moc.Setup(m => m.GetCheckoutTotal(It.IsAny <SkuIdsDto>())).Returns(response);

            promotionEngineController = new PromotionEngineController(moc.Object)
            {
                ControllerContext = new ControllerContext
                {
                    HttpContext = new DefaultHttpContext()
                }
            };

            //Act
            var response1 = promotionEngineController.CheckoutTotal(request);

            //Assert
            Assert.NotNull(response1);
        }
 public PromotionEngineControllerXunit()
 {
     prodcutService            = new ProdcutService();
     promotionBO               = new PromotionBO(prodcutService);
     promotionEngineController = new PromotionEngineController(promotionBO);
 }