Ejemplo n.º 1
0
            public void DeletePromotionIsSuccessful()
            {
                //Arrange
                var promotionToDelete = new Promotion();

                var promotionDaoMock = new Mock<IPromotionDao>();
                var eventTrackingManagerMock = new Mock<IEventTrackingManager>();
                var ratePlanManagerMock = new Mock<IRatePlanManager>();

                promotionDaoMock.Setup(p => p.DeletePromotion(It.Is<int>(i => i == PROMOTION_ID))).Returns(true);
                promotionDaoMock.Setup(p => p.GetByKey(It.Is<int>(i => i == PROMOTION_ID))).Returns(promotionToDelete);
                
                var links = new List<int> { 1, 2 };
                promotionDaoMock.Setup(p => p.GetRatePlanIdsByPromoId(PROMOTION_ID)).Returns(links);
                promotionDaoMock.Setup(p => p.DeleteRatePlanLinks(PROMOTION_ID, links));

                promotionDaoMock.Setup(p => p.GetBlackoutDatesByPromotionId(PROMOTION_ID)).Returns(new List<PromotionBlackoutDate>());
                promotionDaoMock.Setup(p => p.DeleteBlackoutDates(It.IsAny<List<int>>()));

                ratePlanManagerMock.Setup(rpm => rpm.CreateRatePlanUpdateEvent(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()));

                eventTrackingManagerMock.Setup(e => e.CreateBusinessEventAsync(It.Is<long>(i => i == BUSINESS_ID), 
                                                It.Is<BusinessEventTypesEnum>(b => b == BusinessEventTypesEnum.PromotionDeleted),
                                                It.Is<int>(i => i == PROMOTION_ID), It.IsAny<string>()));

                var promotionManager = new PromotionManager
                                           {
                                               EventTrackingManager = eventTrackingManagerMock.Object,
                                               PromotionDao = promotionDaoMock.Object,
                                               RatePlanManager = ratePlanManagerMock.Object
                                           };

                //Act
                var status = promotionManager.DeletePromotion(BUSINESS_ID, PROMOTION_ID);

                //Assert
                Assert.IsTrue(status, "Promotion Manager did not return a successful status");

                promotionDaoMock.VerifyAll();
                eventTrackingManagerMock.VerifyAll();
            }
Ejemplo n.º 2
0
            public void DeletePromotionIsNotSuccesful()
            {
                //Arrange
                var promotionToDelete = new Promotion();

                var promotionDaoMock = new Mock<IPromotionDao>();
                var ratePlanManagerMock = new Mock<IRatePlanManager>();

                promotionDaoMock.Setup(p => p.DeletePromotion(It.Is<int>(i => i == PROMOTION_ID))).Returns(false);
                promotionDaoMock.Setup(p => p.GetByKey(It.Is<int>(i => i == PROMOTION_ID))).Returns(promotionToDelete);
                promotionDaoMock.Setup(p => p.GetRatePlanIdsByPromoId(It.Is<int>(i => i == PROMOTION_ID))).Returns(new List<int>() { RATEPLAN_ID });

                ratePlanManagerMock.Setup(rpm => rpm.CreateRatePlanUpdateEvent(It.IsAny<int>(), It.IsAny<int>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()));

                var promotionManager = new PromotionManager
                {
                    PromotionDao = promotionDaoMock.Object,
                    RatePlanManager = ratePlanManagerMock.Object
                };

                //Act
                var status = promotionManager.DeletePromotion(BUSINESS_ID, PROMOTION_ID);

                //Assert
                Assert.IsFalse(status, "Promotion Manager returned a successful status");

                promotionDaoMock.VerifyAll();
            }