Пример #1
0
            public void DeletePeriodWithRatesExpectDeletionOfRatesToBeExecuted()
            {
                // Arrange
                IVariantRatePlanDao variantRatePlanDaoMock = MockRepository.GenerateMock<IVariantRatePlanDao>();
                IRatePlanDao ratePlanMock = MockRepository.GenerateMock<IRatePlanDao>();
                IEventTrackingManager eventTrackingMock = MockRepository.GenerateMock<IEventTrackingManager>();
                IPeriodDao periodMock = MockRepository.GenerateMock<IPeriodDao>();
                IPeriodDateRangeDao periodDateRangeMock = MockRepository.GenerateMock<IPeriodDateRangeDao>();
                PeriodTypeEnum seasonType = PeriodTypeEnum.Season;

                eventTrackingMock.Expect(bedao => bedao.CreateBusinessEventAsync(Arg<long>.Is.Equal(BUSINESS_ID), Arg<BusinessEventTypesEnum>.Is.Equal(BusinessEventTypesEnum.SeasonPeriodDeleted), Arg<string>.Is.Anything, Arg<string>.Is.Anything));
                variantRatePlanDaoMock.Expect(vrp => vrp.DeleteRatePlanRatesAssociatedWithPeriod(Arg<int>.Is.Equal(PERIOD_WITHRATES_ID))).Return(true);
                periodMock.Expect(pedao => pedao.Remove(Arg<int>.Is.Anything));
                periodDateRangeMock.Expect(pdr => pdr.Remove(Arg<int>.Is.Equal(PERIOD_DATERANGE_ID)));
                periodDateRangeMock.Expect(pdr => pdr.GetAllByPeriodId(Arg<int>.Is.Equal(PERIOD_WITHRATES_ID))).Return(new List<PeriodDateRange> { new PeriodDateRange() }).Repeat.Once();
                

               // set up manager with the mocks
                PeriodManager periodManager = new PeriodManager
                {
                    EventTrackingManager = eventTrackingMock,
                    RatePlanDao = ratePlanMock,
                    PeriodDao = periodMock,
                    PeriodDateRangeDao = periodDateRangeMock,
                    VariantRatePlanDao = variantRatePlanDaoMock
                    
                };

                //Act
                periodManager.DeletePeriod(BUSINESS_ID, seasonType, PERIOD_WITHRATES_ID, PERIOD_DATERANGE_ID);

                // Assert
                eventTrackingMock.VerifyAllExpectations();
                periodMock.VerifyAllExpectations();
                periodDateRangeMock.VerifyAllExpectations();
                variantRatePlanDaoMock.VerifyAllExpectations();
            }  
Пример #2
0
            public void DeleteClosurePeriodWithMoreThanOneDateRangeOnlyDeletesPeriodDateRangeIsSuccessful()
            {
                // Arrange
                IRatePlanDao ratePlanMock = MockRepository.GenerateMock<IRatePlanDao>();
                IEventTrackingManager eventTrackingMock = MockRepository.GenerateMock<IEventTrackingManager>();
                IPeriodDao periodMock = MockRepository.GenerateMock<IPeriodDao>();
                IPeriodDateRangeDao periodDateRangeMock = MockRepository.GenerateMock<IPeriodDateRangeDao>();
                PeriodTypeEnum closureType = PeriodTypeEnum.Closure;

                ratePlanMock.Expect(rpdao => rpdao.DoRatesExistForPeriod(Arg<int>.Is.Equal(PERIOD_WITHOUTRATES_ID))).Return(false).Repeat.Never();
                eventTrackingMock.Expect(bedao => bedao.CreateBusinessEventAsync(Arg<long>.Is.Equal(BUSINESS_ID), Arg<BusinessEventTypesEnum>.Is.Equal(BusinessEventTypesEnum.ClosurePeriodDeleted), Arg<string>.Is.Anything, Arg<string>.Is.Anything)).Repeat.Once();
                periodMock.Expect(pedao => pedao.Remove(Arg<int>.Is.Anything)).Repeat.Never();
                periodDateRangeMock.Expect(pdr => pdr.Remove(Arg<int>.Is.Equal(PERIOD_DATERANGE_ID))).Repeat.Once();
                periodDateRangeMock.Expect(pdr => pdr.GetAllByPeriodId(Arg<int>.Is.Equal(PERIOD_WITHOUTRATES_ID))).Return(new List<PeriodDateRange> { new PeriodDateRange(), new PeriodDateRange() }).Repeat.Once();

                // set up manager with the mocks
                PeriodManager periodManager = new PeriodManager
                {
                    EventTrackingManager = eventTrackingMock,
                    RatePlanDao = ratePlanMock,
                    PeriodDao = periodMock,
                    PeriodDateRangeDao = periodDateRangeMock
                };

                // Act
                periodManager.DeletePeriod(BUSINESS_ID, closureType, PERIOD_WITHOUTRATES_ID, PERIOD_DATERANGE_ID);

                // Assert
                eventTrackingMock.VerifyAllExpectations();
                ratePlanMock.VerifyAllExpectations();
                periodMock.VerifyAllExpectations();
                periodDateRangeMock.VerifyAllExpectations();
            }