Exemplo n.º 1
0
            public void ModifyRatePlanRateNoRatePlanIdThrowsException()
            {
                // Arrange
                var businessEventDao = MockRepository.GenerateMock<IBusinessEventDao>();
                var ratePlanRateDao = MockRepository.GenerateStrictMock<IBaseRatePlanRatesDao>();
                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    BusinessEventDao = businessEventDao,
                    RatePlanRateDao = ratePlanRateDao
                };

                const long BUSINESS_ID = 1;
                const int RATE_PLAN_RATE_ID = 5;

                var ratePlanRate = new RatePlanRate { BusinessId = BUSINESS_ID, Id = RATE_PLAN_RATE_ID };

                ratePlanRateDao.Expect(rp => rp.Modify(Arg<RatePlanRate>.Is.Anything)).Repeat.Never();

                businessEventDao.Expect(be => be.Create(Arg<BusinessEvent>.Is.Anything)).Repeat.Never();

                try
                {
                    // Act
                    ratePlanManager.ModifyRatePlanRates(ratePlanRate);

                    // Assert
                    Assert.Fail("Validation exception was not thrown");
                }
                catch (ValidationException vex)
                {
                    Assert.AreEqual(Errors.SRVEX30098.ToString(), vex.Code, "Incorrect validation exception was thrown");
                    ratePlanRateDao.VerifyAllExpectations();
                    businessEventDao.VerifyAllExpectations();
                }
            }
Exemplo n.º 2
0
            public void ModifyRatePlanRateNullReturnsNull()
            {
                // Arrange
                var businessEventDao = MockRepository.GenerateMock<IBusinessEventDao>();
                var ratePlanRateDao = MockRepository.GenerateStrictMock<IBaseRatePlanRatesDao>();
                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    BusinessEventDao = businessEventDao,
                    RatePlanRateDao = ratePlanRateDao
                };

                ratePlanRateDao.Expect(rp => rp.Modify(Arg<RatePlanRate>.Is.Anything)).Repeat.Never();

                businessEventDao.Expect(be => be.Create(Arg<BusinessEvent>.Is.Anything)).Repeat.Never();

                // Act
                var result = ratePlanManager.ModifyRatePlanRates(null);

                // Assert
                Assert.IsNull(result, "Null was not returned");
                ratePlanRateDao.VerifyAllExpectations();
                businessEventDao.VerifyAllExpectations();
            }
Exemplo n.º 3
0
            public void ModifyRatePlanRateIsSuccessful()
            {
                // Arrange
                var eventTrackingManager = new Mock<IEventTrackingManager>();
                var ratePlanRateDao = new Mock<IBaseRatePlanRatesDao>();

                RatePlanManager ratePlanManager = new RatePlanManager
                {
                    RatePlanRateDao = ratePlanRateDao.Object,
                    EventTrackingManager = eventTrackingManager.Object
                };

                const int RATE_PLAN_ID = 1;
                const long BUSINESS_ID = 1;
                const int RATE_PLAN_RATE_ID = 5;

                var ratePlanRate = new RatePlanRate { BusinessId = BUSINESS_ID, Id = RATE_PLAN_RATE_ID, RatePlanId = RATE_PLAN_ID };

                ratePlanRateDao.Setup(rp => rp.Modify(It.Is<RatePlanRate>(rpr => rpr.Id == RATE_PLAN_RATE_ID && rpr.BusinessId == BUSINESS_ID && rpr.RatePlanId == RATE_PLAN_ID)));

                eventTrackingManager.Setup(be => be.CreateBusinessEventAsync(BUSINESS_ID, BusinessEventTypesEnum.RatePlanRateModified, ratePlanRate.Id.ToString(CultureInfo.InvariantCulture), null));

                // Act
                ratePlanManager.ModifyRatePlanRates(ratePlanRate);

                // Assert
                ratePlanRateDao.VerifyAll();
                eventTrackingManager.VerifyAll();
            }