示例#1
0
        public void DateTimeRange()
        {
            using (AmbientClock.Pause())
            {
                // first test with a single date time
                DateTimeRange range = new DateTimeRange(AmbientClock.UtcNow);

                string longString  = range.ToLongTimeString();
                string shortString = range.ToShortTimeString();
                Assert.IsTrue(longString.Length > shortString.Length);
                string defaultString = range.ToString();
                Assert.IsTrue(String.Equals(longString, defaultString) || String.Equals(shortString, defaultString));

                // now add another date time
                range.AddSample(AmbientClock.UtcNow.AddDays(1));

                longString  = range.ToLongTimeString();
                shortString = range.ToShortTimeString();
                Assert.IsTrue(longString.Length > shortString.Length);
                defaultString = range.ToString();
                Assert.IsTrue(String.Equals(longString, defaultString) || String.Equals(shortString, defaultString));
            }
        }