using System.Linq;
using LeafWeb.Core.Charter;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Parsers;
using LeafWeb.Core.Utility;
using NUnit.Framework;

namespace LeafWeb.Core.Tests.Charter
{
	public class CurveDataConverterTests
	{
		private const string ContentDirectory = @"Parsers\LeafOutputData\";

		[Test]
		public void Convert_Valid()
		{
			var fileInfo = FileUtility.GetContentFile(ContentDirectory, "leafgascomparison.csv");
			LeafGasComparison[] leafGasComparisons;
			using (var parser = new LeafGasComparisonParser(fileInfo))
				leafGasComparisons = parser.Parse();

			var curves = CurveDataConverter.Convert(leafGasComparisons).ToArray();
			Assert.That(curves.Count(),Is.EqualTo(1));
		}

		[Test]
		public void Convert_NoCurveData()
		{
			var fileInfo = FileUtility.GetContentFile(ContentDirectory, "leafgascomparison_NoCurveData.csv");
			LeafGasComparison[] leafGasComparisons;
			using (var parser = new LeafGasComparisonParser(fileInfo))
				leafGasComparisons = parser.Parse();

			var curves = CurveDataConverter.Convert(leafGasComparisons);
			Assert.That(curves.Count(),Is.EqualTo(0));
		}

		[Test]
		public void Convert_PartialCurveData()
		{
			var fileInfo = FileUtility.GetContentFile(ContentDirectory, "leafgascomparison_PartialCurveData.csv");

			LeafGasComparison[] leafGasComparisons;
			using (var parser = new LeafGasComparisonParser(fileInfo))
				leafGasComparisons = parser.Parse();

            //var h = CurveDataConverter.Convert(leafGasComparisons).ToArray();

		    var curves = CurveDataConverter.Convert(leafGasComparisons).ToArray();
		    Assert.That(curves.Count(), Is.EqualTo(1));
        }
    }
}