using System;
using System.Configuration;
using System.Linq;
using LeafWeb.Core.Remote;
using LeafWeb.Core.Utility;
using NUnit.Framework;

namespace LeafWeb.Core.Tests.Remote
{
	[TestFixture]
	public class PiscalSshClientTests
	{
		private readonly PiscalLeafInputFile _testInput =
			new PiscalLeafInputFile
			{
				Filename = "blah",
				LeafInputId = 1,
				Contents = "test".GetBytes(),
				DirectoryName = "TestDirectory"
			};

		private readonly string _piscalConnectionString =
			ConfigurationManager.ConnectionStrings["PiscalServer"].ConnectionString;

		[Test]
		public void SubmitLeafInputFile()
		{
			var client = new PiscalSshClient(_piscalConnectionString);
			client.SubmitLeafInputFile(_testInput);
		}

		[Test]
		public void GetLeafInputStatus()
		{
			var client = new PiscalSshClient(_piscalConnectionString);
			client.GetLeafInputStatus(_testInput);
		}

		[Test]
		public void RetrieveLeafInputResult()
		{
			var client = new PiscalSshClient(_piscalConnectionString);
			var result = client.RetrieveLeafInputResult(_testInput).ToList();
			Console.WriteLine(result[0].Contents.GetString());
		}
	}
}
