Tests: add tests for MoGenerator and MoParser
This commit is contained in:
Родитель
877da47eed
Коммит
84dc89beea
|
@ -37,7 +37,7 @@ namespace Vernacular.Test
|
|||
[TestFixture]
|
||||
public class CatalogTests
|
||||
{
|
||||
private Dictionary<string, ParserResourceCatalog> catalogs = new Dictionary<string, ParserResourceCatalog> ();
|
||||
private List<Tuple<string, ResourceCatalog>> catalogs = new List<Tuple<string, ResourceCatalog>> ();
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void SetUp ()
|
||||
|
@ -46,7 +46,14 @@ namespace Vernacular.Test
|
|||
var parser = new PoParser ();
|
||||
parser.Add (path);
|
||||
var lang = Path.GetFileNameWithoutExtension (path);
|
||||
catalogs.Add (lang, new ParserResourceCatalog (parser) { CurrentIsoLanguageCode = lang });
|
||||
catalogs.Add (new Tuple<string, ResourceCatalog> (lang, new ParserResourceCatalog (parser) { CurrentIsoLanguageCode = lang }));
|
||||
}
|
||||
|
||||
(new GeneratorTests ()).TestMoGenerator ();
|
||||
foreach (var path in Directory.GetFiles ("../../Catalog", "*.mo")) {
|
||||
var lang = Path.GetFileNameWithoutExtension (path);
|
||||
var catalog = new MoCatalog (File.Open (path, FileMode.Open)) { CurrentIsoLanguageCode = lang };
|
||||
catalogs.Add(new Tuple<string, ResourceCatalog> (lang, catalog));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,8 +72,8 @@ namespace Vernacular.Test
|
|||
private void ForEachCatalog (Action<string> action)
|
||||
{
|
||||
foreach (var catalog in catalogs) {
|
||||
Catalog.Implementation = catalog.Value;
|
||||
action (catalog.Key);
|
||||
Catalog.Implementation = catalog.Item2;
|
||||
action (catalog.Item1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,5 +46,15 @@ namespace Vernacular.Test
|
|||
}
|
||||
generator.Generate ("../../Catalog/en_US.pot");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestMoGenerator ()
|
||||
{
|
||||
var generator = new MoGenerator ();
|
||||
foreach (var unit in ParserTests.ParsePo ("../../Catalog/ga.po") ) {
|
||||
generator.Add (unit);
|
||||
}
|
||||
generator.Generate ("../../Catalog/ga.mo");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -45,6 +45,13 @@ namespace Vernacular.Test
|
|||
return new List<ILocalizationUnit> (asm_parser.Parse ());
|
||||
}
|
||||
|
||||
public static List<ILocalizationUnit> ParsePo (string po_file)
|
||||
{
|
||||
var po_parser = new PoParser ();
|
||||
po_parser.Add (po_file);
|
||||
return new List<ILocalizationUnit> (po_parser.Parse ());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestParseAssembly ()
|
||||
{
|
||||
|
@ -54,9 +61,7 @@ namespace Vernacular.Test
|
|||
[Test]
|
||||
public void TestParsePo ()
|
||||
{
|
||||
var po_parser = new PoParser ();
|
||||
po_parser.Add ("../../Catalog/en_US.pot");
|
||||
AssertUnits (new List<ILocalizationUnit> (po_parser.Parse ()));
|
||||
AssertUnits (ParsePo ("../../Catalog/en_US.pot"));
|
||||
}
|
||||
|
||||
private void AssertUnits (List<ILocalizationUnit> units)
|
||||
|
@ -133,4 +138,4 @@ namespace Vernacular.Test
|
|||
Assert.AreEqual (1, gp_n_count, "gp_n_count");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче