changeset 19:bcb6e83752a6

Fixes #33: Add method to get list of available translations * Add tests for translation listing * Add tests for equality methods * Add tests for translation languages
author IBBoard <dev@ibboard.co.uk>
date Tue, 06 Apr 2010 19:03:57 +0000
parents 20189f3a3479
children b3bc581a8433
files IBBoard.Tests.csproj Lang/AbstractTranslationSetTest.cs Lang/TranslationLanguageTest.cs Lang/TranslationTest.cs
diffstat 4 files changed, 60 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/IBBoard.Tests.csproj	Tue Apr 06 18:19:48 2010 +0000
+++ b/IBBoard.Tests.csproj	Tue Apr 06 19:03:57 2010 +0000
@@ -41,6 +41,7 @@
     <Compile Include="Lang\AbstractTranslationSetTest.cs" />
     <Compile Include="Lang\ModifiableTranslationSetTest.cs" />
     <Compile Include="Lang\TranslationXmlLoaderTest.cs" />
+    <Compile Include="Lang\TranslationLanguageTest.cs" />
   </ItemGroup>
   <ItemGroup>
     <Reference Include="System" />
--- a/Lang/AbstractTranslationSetTest.cs	Tue Apr 06 18:19:48 2010 +0000
+++ b/Lang/AbstractTranslationSetTest.cs	Tue Apr 06 19:03:57 2010 +0000
@@ -34,6 +34,19 @@
 			translations = GetTranslationSet("zz");
 			Assert.AreEqual("Unknown (zz)", translations.LanguageName);
 		}
+		
+		[Test()]
+		public void TestEquality()
+		{
+			Assert.AreEqual(GetTranslationSet("en"), GetTranslationSet("en"));
+			Assert.AreNotEqual(GetTranslationSet("en"), GetTranslationSet("it"));
+		}
+
+		[Test()]
+		public void TestHashCodes()
+		{
+			Assert.AreEqual(GetTranslationSet("en").GetHashCode(), GetTranslationSet("en").GetHashCode());
+		}
 
 		protected virtual AbstractTranslationSet GetTranslationSet()
 		{
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Lang/TranslationLanguageTest.cs	Tue Apr 06 19:03:57 2010 +0000
@@ -0,0 +1,37 @@
+// This file (TranslationLanguageTest.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 Affero GPL license, 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 NUnit.Framework;
+
+namespace IBBoard.Lang
+{
+	[TestFixture()]
+	public class TranslationLanguageTest
+	{
+		[Test()]
+		public void TestTranslationSetName()
+		{
+			AbstractTranslationSet translationLang = new TranslationLanguage("en");
+			Assert.AreEqual("English", translationLang.LanguageName);
+			translationLang = new TranslationLanguage("it");
+			Assert.AreEqual("italiano", translationLang.LanguageName);
+			translationLang = new TranslationLanguage("zz");
+			Assert.AreEqual("Unknown (zz)", translationLang.LanguageName);
+		}
+		
+		[Test()]
+		public void TestEquality()
+		{
+			Assert.AreEqual(new TranslationLanguage("en"), new TranslationLanguage("en"));
+			Assert.AreNotEqual(new TranslationLanguage("en"), new TranslationLanguage("it"));
+		}
+		
+		[Test()]
+		public void TestHashCodes()
+		{
+			Assert.AreEqual(new TranslationLanguage("en").GetHashCode(), new TranslationLanguage("en").GetHashCode());
+		}
+	}
+}
--- a/Lang/TranslationTest.cs	Tue Apr 06 18:19:48 2010 +0000
+++ b/Lang/TranslationTest.cs	Tue Apr 06 19:03:57 2010 +0000
@@ -70,5 +70,14 @@
 		{
 			Assert.AreEqual("++ Missing Translation missingID ++", Translation.GetTranslation("missingID"));
 		}
+		
+		[Test()]
+		public void TestLoadedListOfLanguageNames()
+		{
+			Translation.InitialiseTranslations(TEST_DATA_PATH);
+			Assert.AreEqual(2, Translation.GetLanguages().Count);
+			Assert.That(Translation.GetLanguages().Contains(new TranslationLanguage("en")));
+			Assert.That(Translation.GetLanguages().Contains(new TranslationLanguage("it")));
+		}
 	}
 }