using System;
using MileageTraker.Web.ViewModels.FuelLog;
using NUnit.Framework;

namespace Web.Tests.ViewModels.FuelLog
{
	[TestFixture]
	public class ImportFuelLogViewModelTests
	{
		private static readonly ImportFuelLogViewModel Iflvm = new ImportFuelLogViewModel
			{
				Date = new DateTime(2015, 10, 1, 3, 2, 1),
				DriverFullName = "Bob Dobalina",
				TagNumber = "TG2832",
				Odometer = 98323,
				CityName = "Knoxville",
				MPG = 23.1,
				GasPurchased = 2.123,
				TotalPrice = 4.32M
			};

		[Test]
		public void Converts_To_FuelLog()
		{
			var fuelLog = Iflvm.GetFuelLog();
			Assert.That(fuelLog.Date, Is.EqualTo(Iflvm.Date));
		}

		[Test]
		public void Converts_To_FuelLog_And_Back()
		{
			var fuelLog = Iflvm.GetFuelLog();
			var importFuelLogViewModel = new ImportFuelLogViewModel(fuelLog);
			Assert.That(importFuelLogViewModel.TotalPrice, Is.EqualTo(Iflvm.TotalPrice));
		}

		[Test]
		public void Converts_FuelLogLogId()
		{
			var fuelLog = Iflvm.GetFuelLog();
			fuelLog.Log = new MileageTraker.Web.Models.Log {LogId = 123};
			var importFuelLogViewModel = new ImportFuelLogViewModel(fuelLog);
			Assert.That(importFuelLogViewModel.TotalPrice, Is.EqualTo(Iflvm.TotalPrice));
		}
	}
}
