Esempio n. 1
0
        public void GetTimeAgo_WhenGreaterThanADay_ReturnDays(double day, string timeAgo)
        {
            var sut      = new DateService();
            var now      = DateTimeOffset.Now;
            var datetime = now - TimeSpan.FromDays(day);

            var result = sut.GetTimeAgo(datetime);

            Assert.That(result, Is.EqualTo(timeAgo));
        }
Esempio n. 2
0
        public void GetTimeAgo_WhenLessThanADay_ReturnHours(int hour, string timeAgo)
        {
            var sut      = new DateService();
            var now      = DateTimeOffset.Now;
            var datetime = now - TimeSpan.FromHours(hour);

            var result = sut.GetTimeAgo(datetime);

            Assert.That(result, Is.EqualTo(timeAgo));
        }
Esempio n. 3
0
        public void GetTimeAgo_WhenLessThanAMinute_ReturnSeconds(int sec, string timeAgo)
        {
            var sut      = new DateService();
            var now      = DateTimeOffset.Now;
            var datetime = now - TimeSpan.FromSeconds(sec);

            var result = sut.GetTimeAgo(datetime);

            Assert.That(result, Is.EqualTo(timeAgo));
        }
Esempio n. 4
0
        public void GetTimeAgo_WhenLessThanAnHour_ReturnMinutes(int min, string timeAgo)
        {
            var sut      = new DateService();
            var now      = DateTimeOffset.Now;
            var datetime = now - TimeSpan.FromMinutes(min);

            var result = sut.GetTimeAgo(datetime);

            Assert.That(result, Is.EqualTo(timeAgo));
        }
Esempio n. 5
0
        public void GetDate_WhenCalled_ReturnNow()
        {
            var sut = new DateService();

            var datetimeFromService = sut.GetDate();
            var now  = DateTimeOffset.Now;
            var diff = now - datetimeFromService;

            Assert.That(diff < TimeSpan.FromSeconds(1), Is.True);
        }