changeset 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 b3bc581a8433
children e9bad86c1360
files Lang/AbstractTranslationSetTest.cs Lang/ModifiableTranslationSetTest.cs Limits/AbstractLimitTest.cs
diffstat 3 files changed, 27 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/Lang/AbstractTranslationSetTest.cs	Wed Apr 07 14:57:28 2010 +0000
     1.2 +++ b/Lang/AbstractTranslationSetTest.cs	Wed Apr 07 19:36:08 2010 +0000
     1.3 @@ -9,6 +9,10 @@
     1.4  {
     1.5  	public abstract class AbstractTranslationSetTest
     1.6  	{
     1.7 +		protected const string TEST_KEY = "testKey";
     1.8 +		protected const string TEST_VALUE = "testTranslationValue";
     1.9 +		protected const string INHERITED_KEY = "inherited";
    1.10 +		protected const string INHERITED_VALUE = "Inherited Translation";
    1.11  		
    1.12  		[Test()]
    1.13  		public void TestTranslationSetReturnForMissingValue()
    1.14 @@ -21,7 +25,7 @@
    1.15  		public void TestTranslationSetSettingAndRetrieval()
    1.16  		{
    1.17  			AbstractTranslationSet translations = GetTranslationSetWithFixedValue();
    1.18 -			Assert.AreEqual(GetFixedValueTranslation(), translations[GetFixedValueKey()]);
    1.19 +			Assert.AreEqual(TEST_VALUE, translations[TEST_KEY]);
    1.20  		}
    1.21  		
    1.22  		[Test()]
    1.23 @@ -36,6 +40,15 @@
    1.24  		}
    1.25  		
    1.26  		[Test()]
    1.27 +		public void TestTranslationInheritence()
    1.28 +		{
    1.29 +			AbstractTranslationSet translations = GetTranslationSetWithInheritance("it", "en");
    1.30 +			Assert.AreEqual("en", translations.ParentLanguage.Code);
    1.31 +			Assert.AreEqual(TEST_VALUE, translations[TEST_KEY]);
    1.32 +			Assert.AreEqual(INHERITED_VALUE, translations[INHERITED_KEY]);
    1.33 +		}
    1.34 +		
    1.35 +		[Test()]
    1.36  		public void TestEquality()
    1.37  		{
    1.38  			Assert.AreEqual(GetTranslationSet("en"), GetTranslationSet("en"));
    1.39 @@ -54,8 +67,7 @@
    1.40  		}
    1.41  		
    1.42  		protected abstract AbstractTranslationSet GetTranslationSet(string language);		
    1.43 +		protected abstract AbstractTranslationSet GetTranslationSetWithInheritance(string language, string parentLanguage);
    1.44  		protected abstract AbstractTranslationSet GetTranslationSetWithFixedValue();
    1.45 -		protected abstract string GetFixedValueKey();
    1.46 -		protected abstract string GetFixedValueTranslation();
    1.47  	}
    1.48  }
     2.1 --- a/Lang/ModifiableTranslationSetTest.cs	Wed Apr 07 14:57:28 2010 +0000
     2.2 +++ b/Lang/ModifiableTranslationSetTest.cs	Wed Apr 07 19:36:08 2010 +0000
     2.3 @@ -10,27 +10,25 @@
     2.4  	[TestFixture()]
     2.5  	public class ModifiableTranslationSetTest : AbstractTranslationSetTest
     2.6  	{
     2.7 -		private const string TEST_ID = "testString";
     2.8 -		
     2.9 -		protected override string GetFixedValueKey()
    2.10 -		{
    2.11 -			return TEST_ID;
    2.12 -		}
    2.13 -		
    2.14 -		protected override string GetFixedValueTranslation()
    2.15 -		{
    2.16 -			return "new string";
    2.17 -		}
    2.18 -		
    2.19  		protected override AbstractTranslationSet GetTranslationSet(string language)
    2.20  		{
    2.21  			return new ModifiableTranslationSet(language);
    2.22  		}
    2.23  		
    2.24 +		protected override AbstractTranslationSet GetTranslationSetWithInheritance(string language, string parentLanguage)
    2.25 +		{
    2.26 +			ModifiableTranslationSet translations = new ModifiableTranslationSet(language);
    2.27 +			translations.SetTranslation(TEST_KEY, TEST_VALUE);
    2.28 +			ModifiableTranslationSet parentTranslations = new ModifiableTranslationSet(parentLanguage);
    2.29 +			parentTranslations.SetTranslation(INHERITED_KEY, INHERITED_VALUE);
    2.30 +			translations.SetParentTranslations(parentTranslations);
    2.31 +			return translations;
    2.32 +		}
    2.33 +		
    2.34  		protected override AbstractTranslationSet GetTranslationSetWithFixedValue()
    2.35 -		{
    2.36 +		{			
    2.37  			ModifiableTranslationSet translations = new ModifiableTranslationSet("en");
    2.38 -			translations.SetTranslation(GetFixedValueKey(), GetFixedValueTranslation());
    2.39 +			translations.SetTranslation(TEST_KEY, TEST_VALUE);
    2.40  			return translations;
    2.41  		}
    2.42  	}
     3.1 --- a/Limits/AbstractLimitTest.cs	Wed Apr 07 14:57:28 2010 +0000
     3.2 +++ b/Limits/AbstractLimitTest.cs	Wed Apr 07 19:36:08 2010 +0000
     3.3 @@ -7,7 +7,6 @@
     3.4  
     3.5  namespace IBBoard.Limits
     3.6  {
     3.7 -	[TestFixture()]
     3.8  	public abstract class AbstractLimitTest
     3.9  	{
    3.10  		[Test()]