Esempio n. 1
0
 public void TearDown()
 {
     iv       = null;
     valid1   = null;
     valid2   = null;
     invalid1 = null;
     invalid2 = null;
 }
Esempio n. 2
0
        /// <summary>
        /// <para>Overrides the method, which binds the specified data source to this control. In this method the
        /// validation of the data to be binded is implemented</para>
        /// </summary>
        /// <param name="dataSource">
        /// an instance of the IEnumerable. It contains the data elements to be binded to this control. Can not be null.
        /// Should not contain null elements.
        /// </param>
        /// <exception cref="ArgumentNullException">if datasource is null</exception>
        /// <exception cref="ArgumentException">if dataSource contains null elements</exception>
        /// <exception cref="BindDataInvalidException">if the binded data is invalid (not DateTime or string data type,
        /// has incorrect formatting for text string, and so on)</exception>
        protected override void PerformDataBinding(IEnumerable dataSource)
        {
            //Validate
            Helper.ValidateNotNull(dataSource, "dataSource");

            //Bind data
            ItemValidator itemValidator = new ItemValidator(DisplayDateFormat);

            if (!itemValidator.Validate(dataSource))
            {
                throw new BindDataInvalidException("Data could not be bound to the control.");
            }

            base.PerformDataBinding(dataSource);
        }
Esempio n. 3
0
        public void SetUp()
        {
            iv       = new ItemValidator(DateFormat);
            valid1   = new List <DateTime>();
            valid2   = new List <string>();
            invalid1 = new List <string>();
            invalid2 = new List <object>();

            valid1.Add(DateTime.Now);
            valid1.Add(DateTime.Today);

            valid2.Add(DateTime.Now.ToString(DateFormat, CultureInfo.InvariantCulture));
            valid2.Add(DateTime.Today.ToString(DateFormat, CultureInfo.InvariantCulture));

            invalid1.Add(DateTime.Today.ToString("yyyy-dd-MM", CultureInfo.InvariantCulture));

            invalid2.Add(new object());
        }
Esempio n. 4
0
 public void TestConstructorFail2()
 {
     iv = new ItemValidator("   ");
 }
Esempio n. 5
0
 public void TestConstructorFail1()
 {
     iv = new ItemValidator(null);
 }