using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels.Log;
using NUnit.Framework;

namespace Web.Tests.ViewModels.Log
{
	[TestFixture]
	public class LogQueryViewModelTests
	{
		[Test]
		public void YearMonthStartTest()
		{
			var model = new LogQueryViewModel {Year = 2011, Month=1};
			var ym = model.YearMonthStart;
			Assert.That(ym, Is.EqualTo("2011-01"));
		}	
		
		[Test]
		public void YearMonthEndTest()
		{
			var model = new LogQueryViewModel {Year = 2011, Month=1, MonthRange = 3};
			var ym = model.YearMonthEnd;
			Assert.That(ym, Is.EqualTo("2011-03"));
		}

		[Test]
		public void YearMonthEnd_YearRoll_Test()
		{
			var model = new LogQueryViewModel { Year = 2011, Month = 6, MonthRange = 12 };
			var ym = model.YearMonthEnd;
			Assert.That(ym, Is.EqualTo("2012-05"));
		}

		[Test]
		public void YearMonthEnd_YearRoll_NotQuite_Test()
		{
			var model = new LogQueryViewModel { Year = 2011, Month = 1, MonthRange = 12 };
			var ym = model.YearMonthEnd;
			Assert.That(ym, Is.EqualTo("2011-12"));
		}

		[Test]
		public void AllTest()
		{
			var model = new LogQueryViewModel
				{
					Year = 2011, Month = 2, MonthRange = 12,
					EmployeeName = "My Name",
					LogType = MileageLogType.Commuting,
					VehicleId = "1023"
				};
			Assert.That(model.ToString(), Is.EqualTo("2011-02to2012-01_Comm_1023_My-Name"));
		}
	}
}
