using System;
using MileageTraker.Web.Utility;
using NUnit.Framework;

namespace Web.Tests.Utility
{
	[TestFixture]
	public class CustomExtensionsTests
	{
		[Test]
		public void TimeSpan_ToReadableString_Yesterday()
		{
			var s = (DateTime.Today - DateTime.Today.AddDays(-1)).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("Yesterday"));
		}
	
		[Test]
		public void TimeSpan_ToReadableString_Today()
		{
			var s = (DateTime.Today - DateTime.Today).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("Today"));
		}
	
		[Test]
		public void TimeSpan_ToReadableString_TwoDaysAgo()
		{
			var s = (DateTime.Today - DateTime.Today.AddDays(-2)).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("2 days ago"));
		}

		[Test]
		public void TimeSpan_ToReadableString_OneWeekAgo()
		{
			var s = (DateTime.Today - DateTime.Today.AddDays(-7)).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("1 week ago"));
		}

		[Test]
		public void TimeSpan_ToReadableString_OneWeekOneDayAgo()
		{
			var s = (DateTime.Today - DateTime.Today.AddDays(-8)).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("1 week, 1 day ago"));
		}

		[Test]
		public void TimeSpan_ToReadableString_OneWeekTwoDaysAgo()
		{
			var s = (DateTime.Today - DateTime.Today.AddDays(-9)).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("1 week, 2 days ago"));
		}

		[Test]
		public void TimeSpan_ToReadableString_TwoWeeksAgo()
		{
			var s = (DateTime.Today - DateTime.Today.AddDays(-7)).ToVerboseStringHistoric();

			Assert.That(s, Is.EqualTo("1 week ago"));
		}
	}
}
