Exemple #1
0
        /// <summary>
        /// Check if the ControlToValidate is valid
        /// </summary>
        /// <returns>True if control properties is valid</returns>
        protected override bool EvaluateIsValid()
        {
            string value = this.GetControlValidationValue(this.ControlToValidate);

            NhsTime tryParseResult;

            return(NhsTime.TryParseExact(value, out tryParseResult, CultureInfo.CurrentCulture));
        }
Exemple #2
0
        public void ParseInvalidNullIndex()
        {
            NhsTime parsedTime;

            string invalidNullIndexString = "Null:-256";

            Assert.IsFalse(NhsTime.TryParseExact(invalidNullIndexString, out parsedTime, CultureInfo.CurrentCulture), string.Format(CultureInfo.InvariantCulture, "TryParse failed to return false with string of, {0}", invalidNullIndexString));

            invalidNullIndexString = "Null:124";

            Assert.IsFalse(NhsTime.TryParseExact(invalidNullIndexString, out parsedTime, CultureInfo.CurrentCulture), string.Format(CultureInfo.InvariantCulture, "TryParse failed to return false with string of, {0}", invalidNullIndexString));
        }
Exemple #3
0
        public void ParseNullIndex()
        {
            NhsTime time = new NhsTime();

            time.TimeType  = TimeType.NullIndex;
            time.NullIndex = 4;

            NhsTime parsedTime;

            Assert.IsTrue(NhsTime.TryParseExact(time.ToString(), out parsedTime, CultureInfo.CurrentCulture), string.Format(CultureInfo.InvariantCulture, "TryParse failed with time, {0}", time.ToString()));

            Assert.AreEqual <TimeType>(time.TimeType, parsedTime.TimeType, "Parse did not error but TimeType does not match");
            Assert.AreEqual(time.NullIndex, parsedTime.NullIndex, "Parse did not error but NullIndex does not match");
        }
Exemple #4
0
        public void ParseApproximate()
        {
            System.DateTime baseDateTime = System.DateTime.Now;

            NhsTime time = new NhsTime(baseDateTime, true);

            Assert.AreEqual <TimeType>(time.TimeType, TimeType.Approximate, "TimeType should be Approxinmate when set to a date");

            NhsTime parsedTime;

            Assert.IsTrue(NhsTime.TryParseExact(time.ToString(), out parsedTime, CultureInfo.CurrentCulture), string.Format(CultureInfo.InvariantCulture, "TryParse failed with time, {0}", time.ToString()));

            Assert.AreEqual(time.TimeType, parsedTime.TimeType, "Parse did not error but TimeType does not match");
            Assert.AreEqual <string>(time.TimeValue.ToString("HH:mm", CultureInfo.InvariantCulture), parsedTime.TimeValue.ToString("HH:mm", CultureInfo.InvariantCulture), "Parse did not error but TimeValue does not match");
        }