using System;
using AutoMapper;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.Log;
using NUnit.Framework;

namespace Web.Tests.ViewModels.CreateLog
{
	[TestFixture]
	public class LogImportViewModelTests
	{
		private ImportLogViewModel GetTestModel()
		{
			return new ImportLogViewModel
			{
				CityName = "City",
				Date = "10-20-2010",
				EndOdometer = "10010",
				GasPurchased = "1.123",
				LogType = "Commuting",
				Notes = "My Note",
				Purpose = "Training",
				VehicleId = "1021"
			};
		}

		[Test]
		public void GetLog_Correct()
		{
			var vm = GetTestModel();
			var log = vm.GetLog();
			Assert.That(log.CityName, Is.EqualTo(vm.CityName));
			Assert.That(log.Date, Is.EqualTo(new DateTime(2010,10,20)));
			// NOTE: Purpose is set elsewhere
			//Assert.That(log.Purpose.Purpose, Is.EqualTo("Training"));
		}

		[Test]
		[ExpectedException(typeof(AutoMapperMappingException))]
		public void GetLog_GasPurchased_NotNumber()
		{
			var vm = GetTestModel();
			vm.Date = "wrong";
			vm.GetLog();
		}

		//[Test]
		//[ExpectedException(typeof(AutoMapperMappingException))]
		//public void GetLog_Purpose_NotValid()
		//{
		//	var vm = GetTestModel();
		//	vm.Purpose = "uh huh nope";
		//	var log = vm.GetLog();
		//	Assert.That(log.CityName, Is.EqualTo(vm.CityName));
		//	Assert.That(log.Date, Is.EqualTo(new DateTime(2010, 10, 20)));
		//}
	}
}
