using System;
using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels.CreateLog;
using NUnit.Framework;

namespace Web.Tests.ViewModels
{
	[TestFixture]
	public class CreateLogViewModelTests
	{
		[Test]
		public void GetLog_Converts_To_Log()
		{
			var cityName = "My Town";
			var date = DateTime.Today;
			var endOdometer = "1234";
			var ethraId = "4567";
			string gasPurchased = "2.546";
			var mileageLogType = new MileageLogTypeWrapper {Enum = MileageLogType.Commuting};

			var viewModel = 
				new CreateLogViewModel
				{
					CityName = cityName,
					Date = date,
					EndOdometer = endOdometer,
					VehicleId = ethraId,
					GasPurchased = gasPurchased,
					LogType = mileageLogType
				};

			var log = viewModel.GetLog();

			Assert.That(log.CityName, Is.EqualTo(cityName));
			Assert.That(log.Date, Is.EqualTo(date));
			Assert.That(log.EndOdometer.ToString(), Is.EqualTo(endOdometer));
			Assert.That(log.VehicleId, Is.EqualTo(ethraId));
			Assert.That(log.GasPurchased.ToString(), Is.EqualTo(gasPurchased));
			Assert.That(log.LogType.Enum, Is.EqualTo(mileageLogType.Enum));
		}
	}
}
