2019-05-12 22:05:35 +02:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using FluentAssertions;
|
|
|
|
using Xunit;
|
2019-07-21 13:00:02 +02:00
|
|
|
using YamlDotNet.Core;
|
2019-05-12 22:05:35 +02:00
|
|
|
using YamlDotNet.Serialization;
|
|
|
|
|
2020-08-08 22:24:01 +02:00
|
|
|
namespace Tests.Core.Localization
|
2019-05-12 22:05:35 +02:00
|
|
|
{
|
|
|
|
public class Translations_test
|
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void TranslationsYamlIsValid()
|
|
|
|
{
|
|
|
|
// Read the file
|
2020-08-08 22:24:01 +02:00
|
|
|
var translationFile = File.ReadAllText(Path.GetFullPath("./../../../../src/Core/Localization/Translations.yml"));
|
2019-05-12 22:05:35 +02:00
|
|
|
|
|
|
|
// Deserialize
|
|
|
|
var input = new StringReader(translationFile);
|
2019-07-21 13:00:02 +02:00
|
|
|
var mergingParser = new MergingParser(new Parser(input));
|
2019-05-12 22:05:35 +02:00
|
|
|
var deserializer = new DeserializerBuilder().Build();
|
2019-07-21 13:00:02 +02:00
|
|
|
var rawTranslations = deserializer.Deserialize<Dictionary<string, Dictionary<string, Dictionary<string, string>>>>(mergingParser);
|
2019-05-12 22:05:35 +02:00
|
|
|
|
|
|
|
// These languages must be supported
|
|
|
|
var supportedLanguages = new List<string>
|
|
|
|
{
|
|
|
|
"EN",
|
|
|
|
"CHDE"
|
|
|
|
};
|
|
|
|
|
|
|
|
// Iterate every single key to make sure it's populated
|
|
|
|
foreach (var command in rawTranslations)
|
|
|
|
{
|
|
|
|
foreach (var str in command.Value)
|
|
|
|
{
|
|
|
|
str.Value.Select(e => e.Key).ToList().Should().BeEquivalentTo(supportedLanguages, str.Key);
|
|
|
|
foreach (var lang in str.Value)
|
|
|
|
{
|
|
|
|
lang.Value.Should().NotBeNullOrEmpty($"{command.Key} / {str.Key} / {lang.Key}");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|