

using NUnit.Framework;
using System;
using System.IO;
using Exiv2;

namespace Exiv2.Tests
{
	[TestFixture]
	public class ImageTests
	{
	
		string imagefile = "alex.jpg";
		Image image;

		[SetUp]
		public void SetUp ()
		{
			GLib.GType.Init ();
			File.Copy ("../data/" + imagefile, "./" + imagefile, true);
			image = ImageFactory.Open ("./" + imagefile);
			image.ReadMetadata ();
		}

		[TearDown]
		public void TearDown ()
		{
			try {
				File.Delete ("./" + imagefile);
			} catch {}
		}

		[Test]
		public void ReadComment ()
		{
			Assert.IsTrue (String.IsNullOrEmpty (image.Comment));
		}

		[Test]
		public void SetAndReadComment ()
		{
			string comment = "comment set by unit test";
			image.Comment = comment;
			image.WriteMetadata ();

			image = ImageFactory.Open ("./" + imagefile);
			image.ReadMetadata ();
			Assert.AreEqual (image.Comment, comment);
		}

		[Test]
		public void PixelWidthHeight ()
		{
			Assert.AreEqual (image.PixelWidth, 171);
			Assert.AreEqual (image.PixelHeight, 256);
		}
	}
}
