public void SerializeTest()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);
            var mockTimeSpan = mockRepository.Create<IStringSerializer<TimeSpan>>();
            var mockDaysOfWeek = mockRepository.Create<IStringSerializer<DaysOfWeek>>();
            var mockIEnumerableDateTime = mockRepository.Create<IStringSerializer<IEnumerable<DateTime>>>();

            var timeSpanRuleInfoSerializer = new TimeSpanRuleInfoSerializer(mockTimeSpan.Object, mockDaysOfWeek.Object,
                                                                            mockIEnumerableDateTime.Object);

            var expMin = new TimeSpan(150);
            var expMax = new TimeSpan(250);
            var expDaysOfWeek = new DaysOfWeek(DayOfWeek.Monday, DayOfWeek.Thursday);
            var expDateTimes = new[] {new DateTime(1), new DateTime(100), new DateTime(500)};

            var exp = new TimeSpanRuleInfo(expMin, expMax, expDaysOfWeek, expDateTimes);

            mockTimeSpan.Setup(x => x.Serialize(expMin)).Returns("150").Verifiable();
            mockTimeSpan.Setup(x => x.Serialize(expMax)).Returns("250").Verifiable();
            mockDaysOfWeek.Setup(x => x.Serialize(expDaysOfWeek)).Returns("1,4").Verifiable();
            mockIEnumerableDateTime.Setup(x => x.Serialize(expDateTimes)).Returns("datetimes").Verifiable();

            Assert.AreEqual("150\x001E250\x001E1,4\x001Edatetimes", timeSpanRuleInfoSerializer.Serialize(exp));

            mockRepository.VerifyAll();
        }
 public TimeSpanRule(TimeSpanRuleInfo ruleInfo,
                     IDayOfWeekLoop dayOfWeekLoop)
 {
     _ruleInfo = ruleInfo;
     _dayOfWeekLoop = dayOfWeekLoop;
     Validate();
 }
 protected bool Equals(TimeSpanRuleInfo other)
 {
     return DateTimes.SequenceEqual(other.DateTimes) && DayTimeFrom.Equals(other.DayTimeFrom) &&
            DayTimeTo.Equals(other.DayTimeTo) && Equals(DaysOfWeek, other.DaysOfWeek);
 }
 public TimeSpanRule(TimeSpanRuleInfo ruleInfo)
     : this(ruleInfo, new DayOfWeekLoop())
 {
 }