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

namespace InventoryTraker.Web.Tests.Utilities
{
	[TestFixture]
	public class DistributionReportWriterTests
	{
		private IMapper _mapper;

		[OneTimeSetUp]
		public void StartUp()
		{
			_mapper = AutoMapperConfig.Config.CreateMapper();
		}

		private readonly DistributionReport[] _distributionReports =
		{
			new DistributionReport
			{
				Destination = "First City",
				Date = new DateTime(2016, 1, 1),
				Transactions = new[]
				{
					new TransactionViewModel
					{
						Name = "Beans",
						ContainerType = "#300 cans",
						UnitsPerCase = 24,
						Destination = "First City",
						RemovedQuantity = 3
					}
				}
			},
			new DistributionReport
			{
				Destination = "Second City",
				Date = new DateTime(2016, 2, 1),
				Transactions = new[]
				{
					new TransactionViewModel
					{
						Name = "Peanut Butter",
						ContainerType = "Jars",
						UnitsPerCase = 24,
						Destination = "Second City",
						RemovedQuantity = 4
					}
				}
			}
		};

		[Test, Explicit]
		public void Write()
		{
			using 
				(var outputFile 
					= new StreamWriter(Path.Combine(@"c:\temp", "DistributionReport.xlsx")))
			{
				var writer = new DistributionReportWriter(_mapper);
				writer.WriteStream(_distributionReports, outputFile.BaseStream);
			}
		}
	}
}
