using System;
using LeafWeb.Core.Utility;
using NUnit.Framework;

namespace LeafWeb.Core.Tests.Utility
{
	[TestFixture]
	public class TimeSpanExtensionsTests
	{
		[Test]
		public void ToRoundedReadableString_1Sec()
		{
			var ts = TimeSpan.FromSeconds(1);
			var result = ts.ToRoundedReadableString(abbreviation:true);
			Assert.That(result, Is.EqualTo("1 sec."));
		}

		[Test]
		public void ToRoundedReadableString_2Sec()
		{
			var ts = TimeSpan.FromSeconds(2);
			var result = ts.ToRoundedReadableString(abbreviation:true);
			Assert.That(result, Is.EqualTo("2 secs."));
		}

		[Test]
		public void ToRoundedReadableString_1Hr()
		{
			var ts = TimeSpan.FromHours(1);
			var result = ts.ToRoundedReadableString(abbreviation:true);
			Assert.That(result, Is.EqualTo("1 hr."));
		}

		[Test]
		public void ToRoundedReadableString_2Hr()
		{
			var ts = TimeSpan.FromHours(2);
			var result = ts.ToRoundedReadableString(abbreviation:true);
			Assert.That(result, Is.EqualTo("2 hrs."));
		}
	}
}
