Example #1
0
        public void TestArgumentNotOfTypeDateTime()
        {
            SetThreadCulture();

            string result = new DateTimeAgoConverter().Convert(4, typeof(string), null, Thread.CurrentThread.CurrentCulture) as string;

            Assert.Equal(result, string.Empty);
        }
Example #2
0
        public void TestArgumentOfYesterday()
        {
            SetThreadCulture();

            DateTime dateTime = DateTime.Now.AddDays(-1);

            string result = new DateTimeAgoConverter().Convert(dateTime, typeof(string), null, Thread.CurrentThread.CurrentCulture) as string;

            Assert.Equal(result, dateTime.ToShortDateString());
        }
        public void TestArgumentOfSameDay()
        {
            SetThreadCulture();

            DateTime dateTime = DateTime.Now;

            string result = new DateTimeAgoConverter().Convert(dateTime, typeof(string), null, Thread.CurrentThread.CurrentCulture) as string;

            Assert.AreEqual(result, dateTime.ToShortTimeString());
        }