Пример #1
0
        public void ParseNotApproximateTruePassedToToString()
        {
            System.DateTime baseDateTime = System.DateTime.Now;

            NhsTime time = new NhsTime(baseDateTime);

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

            NhsTime.ParseExact(time.ToString(true), CultureInfo.CurrentCulture);
        }
Пример #2
0
        public void ParseWithAMPMDesignator()
        {
            GlobalizationService gs  = new GlobalizationService();
            DateTime             now = DateTime.Now;
            string  formattedTime    = now.ToString(gs.ShortTimePatternWithSecondsAMPM, CultureInfo.CurrentCulture);
            NhsTime time             = NhsTime.ParseExact(formattedTime, CultureInfo.CurrentCulture);

            Assert.AreEqual <int>(now.Hour, time.TimeValue.Hour, "Parse failed to set hours with am/pm designator");
            Assert.AreEqual <int>(now.Minute, time.TimeValue.Minute, "Parse failed to set minutes with am/pm designator");
            Assert.AreEqual <int>(now.Second, time.TimeValue.Second, "Parse failed to set seconds with am/pm designator");
        }
Пример #3
0
        public void ToStringDisplayAMPM()
        {
            NhsTime morningTime   = NhsTime.ParseExact("10:00:00", CultureInfo.CurrentCulture);
            NhsTime afternoonTime = NhsTime.ParseExact("15:00:00", CultureInfo.CurrentCulture);

            string formattedMorningTime   = morningTime.ToString(false, CultureInfo.CurrentCulture, false, true, true);
            string formattedAfternoonTime = afternoonTime.ToString(false, CultureInfo.CurrentCulture, false, true, true);
            string morningDesignator      = CultureInfo.CurrentCulture.DateTimeFormat.AMDesignator.ToLower(CultureInfo.CurrentCulture);
            string afternoonDesignator    = CultureInfo.CurrentCulture.DateTimeFormat.PMDesignator.ToLower(CultureInfo.CurrentCulture);

            Assert.IsTrue(formattedMorningTime.Contains(morningDesignator));
            Assert.IsTrue(formattedAfternoonTime.Contains(afternoonDesignator));
        }
Пример #4
0
        public void ParseEmptyString()
        {
            NhsTime time = NhsTime.ParseExact(string.Empty, CultureInfo.CurrentCulture);

            Assert.AreEqual <TimeType>(time.TimeType, TimeType.Null, "Parse did not error but TimeType does not match");
        }
Пример #5
0
        public void ParseWithSeconds()
        {
            NhsTime time = NhsTime.ParseExact("10:30:23", CultureInfo.CurrentCulture);

            Assert.AreEqual <int>(time.TimeValue.Second, 23, "Parse failed to set seconds");
        }
Пример #6
0
 public void ParseShouldFail()
 {
     NhsTime.ParseExact("barf", CultureInfo.CurrentCulture);
 }
Пример #7
0
 /// <summary>
 /// Set the value to 23:59.
 /// </summary>
 /// <param name="sender">Sender of the event.</param>
 /// <param name="e">Event args for the event.</param>
 private void SetTo2359Button_Click(object sender, EventArgs e)
 {
     this.timeInputBox3.Value = NhsTime.ParseExact("23:59", CultureInfo.CurrentCulture);
 }