Mercurial > repos > IBBoard.Tests
annotate Lang/TranslationTest.cs @ 15:e3e4f7a92f8b
Re #31: Break out Translations for language to own class
* Add tests for translation sets
Re #30: Improve Translations API
* Add more tests
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Tue, 06 Apr 2010 15:43:08 +0000 |
parents | 15cf2fe2a627 |
children | bcb6e83752a6 |
rev | line source |
---|---|
14 | 1 // This file (TranslationTest.cs) is a part of the IBBoard.Tests project and is copyright 2010 IBBoard |
2 // | |
3 // 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. | |
4 | |
5 using System; | |
6 using NUnit.Framework; | |
7 using IBBoard.Lang.Mock; | |
8 | |
9 namespace IBBoard.Lang | |
10 { | |
11 [TestFixture()] | |
12 public class TranslationTest | |
13 { | |
14 private const string TEST_ID = "testString"; | |
15 private const string TEST_DATA_PATH = "test-data"; | |
16 | |
17 [SetUp()] | |
18 public void Setup() | |
19 { | |
20 Translation.Reset(); | |
21 } | |
22 | |
23 [Test()] | |
24 public void TestMissingTranslationGivesMissingMessage() | |
25 { | |
26 Assert.AreEqual("++ Missing Translation missingID ++", Translation.GetTranslation("missingID")); | |
27 Assert.AreEqual("++ Missing Translation missingID ++", Translation.GetTranslation("missingID", false)); | |
28 string defaultMessage = "default message"; | |
29 Assert.AreEqual(defaultMessage, Translation.GetTranslation("missingID", defaultMessage)); | |
30 Assert.IsNull(Translation.GetTranslation("missingID", true)); | |
31 } | |
32 | |
33 [Test()] | |
34 public void TestInitialiseTranslations() | |
35 { | |
36 Assert.AreEqual("++ Missing Translation "+TEST_ID+" ++", Translation.GetTranslation(TEST_ID)); | |
37 Translation.InitialiseTranslations(TEST_DATA_PATH, "en"); | |
38 Assert.AreEqual("Test String", Translation.GetTranslation(TEST_ID)); | |
39 Assert.AreEqual("en", Translation.GetTranslationLanguage()); | |
40 Translation.InitialiseTranslations(TEST_DATA_PATH, "it"); | |
41 Assert.AreEqual("Fakius Romanius", Translation.GetTranslation(TEST_ID)); | |
42 Assert.AreEqual("it", Translation.GetTranslationLanguage()); | |
43 } | |
44 | |
45 [Test()] | |
46 public void TestLoadTranslations() | |
47 { | |
48 Assert.AreEqual("++ Missing Translation "+TEST_ID+" ++", Translation.GetTranslation(TEST_ID)); | |
49 Translation.InitialiseTranslations(TEST_DATA_PATH, "en"); | |
50 Assert.AreEqual("Test String", Translation.GetTranslation(TEST_ID)); | |
51 Assert.AreEqual("en", Translation.GetTranslationLanguage()); | |
52 Translation.LoadTranslation("it"); | |
53 Assert.AreEqual("Fakius Romanius", Translation.GetTranslation(TEST_ID)); | |
54 Assert.AreEqual("it", Translation.GetTranslationLanguage()); | |
55 } | |
56 | |
57 [Test()] | |
58 public void TestITranslationTranslation() | |
59 { | |
60 MockTranslatable translatable = new MockTranslatable(TEST_ID); | |
61 Translation.Translate(translatable); | |
62 Assert.AreEqual("++ Missing Translation "+TEST_ID+" ++", translatable.Text); | |
63 Translation.InitialiseTranslations(TEST_DATA_PATH, "en"); | |
64 Translation.Translate(translatable); | |
65 Assert.AreEqual("Test String", translatable.Text); | |
66 } | |
15
e3e4f7a92f8b
Re #31: Break out Translations for language to own class
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
67 |
e3e4f7a92f8b
Re #31: Break out Translations for language to own class
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
68 [Test()] |
e3e4f7a92f8b
Re #31: Break out Translations for language to own class
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
69 public void TestResetDoesNotCauseErrors() |
e3e4f7a92f8b
Re #31: Break out Translations for language to own class
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
70 { |
e3e4f7a92f8b
Re #31: Break out Translations for language to own class
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
71 Assert.AreEqual("++ Missing Translation missingID ++", Translation.GetTranslation("missingID")); |
e3e4f7a92f8b
Re #31: Break out Translations for language to own class
IBBoard <dev@ibboard.co.uk>
parents:
14
diff
changeset
|
72 } |
14 | 73 } |
74 } |