using System;
using NUnit.Framework;
using Moq;
using Rothko.UI.Interfaces.Dal;
using Rothko.UI.Model;
using System.Collections.Generic;

namespace Rothko.Tests.UI.Dal
{
	[TestFixture]
	public abstract class UIRothkoDatabaseTests
	{
		protected IUIRothkoDatabase _Database;

		protected abstract IUIRothkoDatabase GetNewDatabase();

		protected UIStructureType _UIStructureType;

		[SetUp]
		public void SetUp()
		{
			_Database = GetNewDatabase();

			_UIStructureType = new UIStructureType();
		}

		[Test]
		public void UIStructureTypeSaveShouldSaveNewRecordIfIDIsZero()
		{
			_UIStructureType.ID = 0;
			_UIStructureType.Animation = new Animation() 
			{ 
				Frames = new List<AnimationFrame>()
				{
					new AnimationFrame() 
					{ 
						IDAsset = 1, 
						Duration = 10 
					} 
				}
			};

			Assert.AreEqual(0, _Database.GetUIStructureTypes().Count);

			_Database.SaveUIStructureType(_UIStructureType);

			Assert.AreEqual(1, _Database.GetUIStructureTypes().Count);
			Assert.AreEqual(10, _Database.GetUIStructureTypes()[0].Animation.Frames[0].Duration);
		}
	}
}

