Пример #1
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (Name == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Name");
     }
     if (Capacity == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Capacity");
     }
     if (Rules == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "Rules");
     }
     if (Capacity != null)
     {
         Capacity.Validate();
     }
     if (Rules != null)
     {
         foreach (var element in Rules)
         {
             if (element != null)
             {
                 element.Validate();
             }
         }
     }
     if (FixedDate != null)
     {
         FixedDate.Validate();
     }
     if (Recurrence != null)
     {
         Recurrence.Validate();
     }
 }
        public void TestFixedDates()
        {
            var complexDate = new FixedDate() {Day = 6, Month = 2};

            AssertDates(complexDate.NextDates(new DateTime(2011, 2, 6)),
                new DateTime(2012, 2, 6),
                new DateTime(2013, 2, 6),
                new DateTime(2014, 2, 6),
                new DateTime(2015, 2, 6),
                new DateTime(2016, 2, 6));
        }
        public void TestFixedDateWithYear()
        {
            var complexDate = new FixedDate() { Day = 6, Month = 2, Year = 2010};

            Assert.AreEqual(
                new DateTime(2010, 2, 6),
                complexDate.NextDate(new DateTime(2009, 2, 6)));

            Assert.AreEqual(
                null,
                complexDate.NextDate(new DateTime(2010, 2, 6)));
        }
        public void TestFixedDateOnLeapYear()
        {
            var complexDate = new FixedDate() { Day = 29, Month = 2 };

            AssertDates(complexDate.NextDates(new DateTime(2011, 1, 1)),
                new DateTime(2012, 2, 29),
                new DateTime(2016, 2, 29),
                new DateTime(2020, 2, 29),
                new DateTime(2024, 2, 29),
                new DateTime(2028, 2, 29));

            Assert.AreEqual(new DateTime(2016, 2, 29), complexDate.NextDate(new DateTime(2012, 2, 29)));
            Assert.AreEqual(new DateTime(2012, 2, 29), complexDate.NextDate(new DateTime(2011, 3, 1)));
            Assert.AreEqual(new DateTime(2016, 2, 29), complexDate.NextDate(new DateTime(2012, 3, 1)));
        }