using System.Linq;
using MileageTraker.Web.DAL;
using NUnit.Framework;

namespace Web.Tests.DAL
{
	[TestFixture]
	public class LogImporterTests
	{
		private const string LogFolder = @"DAL\LogDocs\";

		[Test]
		public void Import_Gets_More_Than_One_Result()
		{
			var logs = LogImporter.Import(LogFolder + "Logs.xls").ToList();

			Assert.That(logs.Count(), Is.GreaterThan(0));
			var first = logs.First();
			Assert.That(first.VehicleId, Is.EqualTo("3572"));
			Assert.That(first.Date, Is.EqualTo("2/5/2014"));
		}

		[Test]
		[ExpectedException(typeof(LogImportException))]
		public void Import_Incorrect_ColumnHeaders()
		{
			LogImporter.Import(LogFolder + "Logs_IncorrectHeaders.xls").ToList();
		}

		[Test]
		public void Import_TemplateTest()
		{
			var logs = LogImporter.Import(LogFolder + "MileageTraker_ImportTemplate.xls");
			Assert.That(logs.Count(), Is.EqualTo(1));
		}
	}
}
