示例#1
0
        public void Generate_For_Whole_Week_Returns_Occurence_For_Every_Day()
        {
            // Arrange
            var sut         = new WeeklyOccurenceFactory();
            var eventEntity = new WeeklyOccurenceTestDataBuilder()
                              .ForAllDays()
                              .Build();

            var occurenceFactoryParams = CreateFactoryParams();

            // Act
            var result = sut.Create(eventEntity, occurenceFactoryParams);

            // Assert
            result.Should().HaveCount((occurenceFactoryParams.EndDate - occurenceFactoryParams.StartDate).Days);

            foreach (var dayOfWeek in new[]
            {
                DayOfWeek.Monday,
                DayOfWeek.Tuesday,
                DayOfWeek.Wednesday,
                DayOfWeek.Thursday,
                DayOfWeek.Friday,
                DayOfWeek.Saturday,
                DayOfWeek.Sunday
            })
            {
                ValidateForDay(occurenceFactoryParams, result, dayOfWeek);
            }
        }
示例#2
0
        public void Generate_For_Monday_Returns_Tuesdays()
        {
            // Arrange
            var sut         = new WeeklyOccurenceFactory();
            var eventEntity = new WeeklyOccurenceTestDataBuilder()
                              .ForTuesday()
                              .Build();

            var occurenceFactoryParams = CreateFactoryParams();

            // Act
            var result = sut.Create(eventEntity, occurenceFactoryParams);

            // Assert
            ValidateForDay(occurenceFactoryParams, result, DayOfWeek.Tuesday, true);
        }
示例#3
0
        public void Generate_For_Event_That_Has_Start_And_End_Date_Returns_Every_Day_Occurence()
        {
            // Arrange
            var sut         = new WeeklyOccurenceFactory();
            var eventEntity = new WeeklyOccurenceTestDataBuilder()
                              .ForAllDays()
                              .ForPeriod(new DateTime(2001, 1, 10), new DateTime(2001, 1, 20))
                              .Build();

            var occurenceFactoryParams = CreateFactoryParams(new DateTime(2001, 1, 1), new DateTime(2001, 3, 1));

            // Act
            var result = sut.Create(eventEntity, occurenceFactoryParams);

            // Assert
            result.Should().HaveCount((eventEntity.Schedule.EndDateTime - eventEntity.Schedule.StartDateTime).Value.Days + 1);

            result.Should().NotContain(element => element.Date <eventEntity.Schedule.StartDateTime ||
                                                                element.Date> eventEntity.Schedule.EndDateTime);
        }