using System;
using System.IO;
using InventoryTraker.Web.Utilities;
using NUnit.Framework;

namespace InventoryTraker.Web.Tests.Utilities
{
	[TestFixture]
	public class InventoryParserTests
	{
		private readonly string _documentFolder =
			AppDomain.CurrentDomain.BaseDirectory + @"\Utilities\Documents\";

		[Test]
		public void Parse()
		{
			var fileInfo = new FileInfo(Path.Combine(_documentFolder, "InventoryData.xlsx"));

			var parser = new InventoryParser(fileInfo);

			var forms = parser.Parse();

			Assert.That(forms.Count, Is.GreaterThan(0));

			foreach (var form in forms)
			{
				Console.WriteLine($"{form.Id} {form.ProgramName} {form.ShredReadyDate}");
			}
		}

		[Test]
		public void Parse_NullableValues()
		{
			var fileInfo = new FileInfo(Path.Combine(_documentFolder, "InventoryData.xlsx"));

			var parser = new InventoryParser(fileInfo);

			var forms = parser.Parse();

			Assert.That(forms[0].ProgramSubtype, Is.Null);
		}

		[Test]
		public void Parse_ImportTemplate()
		{
			var fileInfo = new FileInfo(Path.Combine(_documentFolder, "InventoryTraker_ImportTemplate.xlsx"));

			var parser = new InventoryParser(fileInfo);

			var forms = parser.Parse();

			Assert.That(forms.Count, Is.EqualTo(1));
		}
	}
}
