view Lang/XmlTranslationSetTest.cs @ 28:31fdc90f3556

* Fix license comments at top of files no-open-ticket
author IBBoard <dev@ibboard.co.uk>
date Sat, 21 Aug 2010 10:07:09 +0000
parents 8a350c00797e
children
line wrap: on
line source

//  This file (XmlTranslationSet.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard
// 
// The file and the library/program it is in are licensed and distributed, without warranty, under the GNU LGPL, either version 3 of the License or (at your option) any later version. Please see COPYING for more information and the full license.

using System;
using System.Xml;
using NUnit.Framework;

namespace IBBoard.Lang
{
	[TestFixture()]
	public class XmlTranslationSetTest : AbstractTranslationSetTest
	{
		protected override AbstractTranslationSet GetTranslationSet(string language)
		{
			return new XmlTranslationSet(language);
		}
		
		protected override AbstractTranslationSet GetTranslationSetWithFixedValue()
		{
			XmlTranslationSet translationSet = new XmlTranslationSet("en");
			XmlDocument doc = new XmlDocument();
			doc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><translations xmlns=\"http://ibboard.co.uk/translation\" lang=\"en\"><translation id=\""+TEST_KEY+"\">"+TEST_VALUE+"</translation></translations>");
			translationSet.SetTranslationNodes(new TranslationXmlExtractor().GetTranslationNodes(doc));
			return translationSet;
		}

		protected override AbstractTranslationSet GetTranslationSetWithInheritance(string language, string parentLanguage)
		{
			XmlTranslationSet translationSet = new XmlTranslationSet(language);
			XmlDocument doc = new XmlDocument();
			doc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?><translations xmlns=\"http://ibboard.co.uk/translation\" lang=\""+language+"\" extends=\""+parentLanguage+"\"><translation id=\""+TEST_KEY+"\">"+TEST_VALUE+"</translation></translations>");
			translationSet.SetTranslationNodes(new TranslationXmlExtractor().GetTranslationNodes(doc));
			translationSet.SetParentLanguage(parentLanguage);
			ModifiableTranslationSet parentTranslationSet = new ModifiableTranslationSet(parentLanguage);
			parentTranslationSet.SetTranslation(INHERITED_KEY, INHERITED_VALUE);
			Translation.AddTranslationSet(parentTranslationSet);
			return translationSet;
		}
		
		protected override AbstractTranslationSet GetTranslationSetWithDirectLoop()
		{
			XmlTranslationSet translations = new XmlTranslationSet("en-US");
			XmlTranslationSet parentTranslations = new XmlTranslationSet("en");
			translations.SetParentLanguage("en");
			parentTranslations.SetParentLanguage("en-US");
			Translation.AddTranslationSet(translations);
			Translation.AddTranslationSet(parentTranslations);
			return translations;
		}
		
		protected override AbstractTranslationSet GetTranslationSetWithIndirectLoop()
		{
			XmlTranslationSet translations = new XmlTranslationSet("it");
			XmlTranslationSet parentTranslations = new XmlTranslationSet("en-US");
			XmlTranslationSet parentParentTranslations = new XmlTranslationSet("en");
			translations.SetParentLanguage("en-US");
			parentTranslations.SetParentLanguage("en");
			parentParentTranslations.SetParentLanguage("it");
			Translation.AddTranslationSet(translations);
			Translation.AddTranslationSet(parentTranslations);
			Translation.AddTranslationSet(parentParentTranslations);
			return translations;
		}
	}
}