diff Lang/AbstractTranslationSetTest.cs @ 21:2834da2b8891

Re #35: Add multi-level cascading of translations * Add tests of "parent language" property * Move some test values to constants instead of abstract methods Also: * Fix warning about tests not being executable because they're on an abstract class by not marking abstract class as a test fixture
author IBBoard <dev@ibboard.co.uk>
date Wed, 07 Apr 2010 19:36:08 +0000
parents bcb6e83752a6
children e9bad86c1360
line wrap: on
line diff
--- a/Lang/AbstractTranslationSetTest.cs	Wed Apr 07 14:57:28 2010 +0000
+++ b/Lang/AbstractTranslationSetTest.cs	Wed Apr 07 19:36:08 2010 +0000
@@ -9,6 +9,10 @@
 {
 	public abstract class AbstractTranslationSetTest
 	{
+		protected const string TEST_KEY = "testKey";
+		protected const string TEST_VALUE = "testTranslationValue";
+		protected const string INHERITED_KEY = "inherited";
+		protected const string INHERITED_VALUE = "Inherited Translation";
 		
 		[Test()]
 		public void TestTranslationSetReturnForMissingValue()
@@ -21,7 +25,7 @@
 		public void TestTranslationSetSettingAndRetrieval()
 		{
 			AbstractTranslationSet translations = GetTranslationSetWithFixedValue();
-			Assert.AreEqual(GetFixedValueTranslation(), translations[GetFixedValueKey()]);
+			Assert.AreEqual(TEST_VALUE, translations[TEST_KEY]);
 		}
 		
 		[Test()]
@@ -36,6 +40,15 @@
 		}
 		
 		[Test()]
+		public void TestTranslationInheritence()
+		{
+			AbstractTranslationSet translations = GetTranslationSetWithInheritance("it", "en");
+			Assert.AreEqual("en", translations.ParentLanguage.Code);
+			Assert.AreEqual(TEST_VALUE, translations[TEST_KEY]);
+			Assert.AreEqual(INHERITED_VALUE, translations[INHERITED_KEY]);
+		}
+		
+		[Test()]
 		public void TestEquality()
 		{
 			Assert.AreEqual(GetTranslationSet("en"), GetTranslationSet("en"));
@@ -54,8 +67,7 @@
 		}
 		
 		protected abstract AbstractTranslationSet GetTranslationSet(string language);		
+		protected abstract AbstractTranslationSet GetTranslationSetWithInheritance(string language, string parentLanguage);
 		protected abstract AbstractTranslationSet GetTranslationSetWithFixedValue();
-		protected abstract string GetFixedValueKey();
-		protected abstract string GetFixedValueTranslation();
 	}
 }