-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dd9f9c4
commit 1027642
Showing
31 changed files
with
426 additions
and
185 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
PG.StarWarsGame.Files.DAT/PG.StarWarsGame.Files.DAT/PG.StarWarsGame.Files.DAT.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ion/PG.StarWarsGame.Localisation.Test/Commons/Helper/AlamoLanguageDefinitionHelperTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Alamo Engine Tools and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for details. | ||
|
||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using PG.Commons.Attributes; | ||
using PG.StarWarsGame.Localisation.Attributes; | ||
using PG.StarWarsGame.Localisation.Commons.Helper; | ||
using PG.StarWarsGame.Localisation.Languages; | ||
using PG.Testing; | ||
|
||
namespace PG.StarWarsGame.Localisation.Test.Commons.Helper; | ||
|
||
[TestClass] | ||
public class AlamoLanguageDefinitionHelperTest : ServiceTestBase | ||
{ | ||
[TestMethod] | ||
public void Test_GetAllAlamoLanguageDefinitions__ReturnsAtLeastDefaults() | ||
{ | ||
var definitions = GetServiceInstance<AlamoLanguageDefinitionHelper>() | ||
.GetAllRegisteredAlamoLanguageDefinitions(); | ||
Assert.IsTrue(definitions.Count >= LocalisationTestConstants.RegisteredLanguageDefinitions.Count, | ||
"This function should always at least return the default language definitions."); | ||
var actualNumberOfLanguageDefinitionsMarkedAsOfficial = 0; | ||
var actualDefaultLanguageCount = 0; | ||
foreach (var alamoLanguageDefinition in definitions) | ||
{ | ||
if (alamoLanguageDefinition.GetType() | ||
.GetAttributeValueOrDefault((OfficiallySupportedLanguageAttribute o) => o.IsOfficiallySupported)) | ||
{ | ||
actualNumberOfLanguageDefinitionsMarkedAsOfficial++; | ||
} | ||
|
||
if (alamoLanguageDefinition.GetType() | ||
.GetAttributeValueOrDefault((DefaultLanguageAttribute d) => d.IsDefaultLanguage)) | ||
{ | ||
actualDefaultLanguageCount++; | ||
} | ||
} | ||
|
||
Assert.AreEqual(LocalisationTestConstants.RegisteredLanguageDefinitions.Count, | ||
actualNumberOfLanguageDefinitionsMarkedAsOfficial, | ||
"Someone added a language definition marked as official. This should not happen. Please remove the OfficiallySupportedLanguageAttribute from the offending language."); | ||
Assert.AreEqual(1, actualDefaultLanguageCount, | ||
"Someone added a language definition marked as default. This should not happen. Please remove the DefaultAttribute from the offending language."); | ||
} | ||
|
||
[TestMethod] | ||
public void Test_GetDefaultAlamoLanguageDefinition__ReturnsCorrectLanguage() | ||
{ | ||
var l = GetServiceInstance<AlamoLanguageDefinitionHelper>().GetDefaultAlamoLanguageDefinition(); | ||
Assert.AreEqual(LocalisationTestConstants.DefaultLanguage, l.GetType()); | ||
var actual = | ||
Activator.CreateInstance(LocalisationTestConstants.DefaultLanguage) as IAlamoLanguageDefinition; | ||
Assert.AreEqual(actual, l); | ||
} | ||
|
||
protected override Type GetServiceClass() | ||
{ | ||
return typeof(AlamoLanguageDefinitionHelper); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 20 additions & 22 deletions
42
PG.StarWarsGame.Localisation/PG.StarWarsGame.Localisation.Test/LocalisationTestConstants.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
// Copyright (c) Alamo Engine Tools and contributors. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for details. | ||
|
||
using PG.Core.Test; | ||
using PG.StarWarsGame.Localisation.Languages; | ||
using System; | ||
using System.Collections.Generic; | ||
using PG.StarWarsGame.Localisation.Languages.Builtin; | ||
using PG.Testing; | ||
|
||
namespace PG.StarWarsGame.Localisation.Test | ||
namespace PG.StarWarsGame.Localisation.Test; | ||
|
||
public sealed class LocalisationTestConstants : TestConstants | ||
{ | ||
public sealed class LocalisationTestConstants : TestConstants | ||
public static readonly IList<Type> RegisteredLanguageDefinitions = new List<Type> | ||
{ | ||
public static readonly IList<Type> REGISTERED_LANGUAGE_DEFINITIONS = new List<Type> | ||
{ | ||
//[gruenwaldlu, 2021-04-18-12:02:51+2]: All officially supported languages are listed below. | ||
typeof(ChineseAlamoLanguageDefinition) | ||
, typeof(EnglishAlamoLanguageDefinition) | ||
, typeof(FrenchAlamoLanguageDefinition) | ||
, typeof(GermanAlamoLanguageDefinition) | ||
, typeof(ItalianAlamoLanguageDefinition) | ||
, typeof(JapaneseAlamoLanguageDefinition) | ||
, typeof(KoreanAlamoLanguageDefinition) | ||
, typeof(PolishAlamoLanguageDefinition) | ||
, typeof(RussianAlamoLanguageDefinition) | ||
, typeof(SpanishAlamoLanguageDefinition) | ||
, typeof(ThaiAlamoLanguageDefinition) | ||
}; | ||
typeof(ChineseAlamoLanguageDefinition), | ||
typeof(EnglishAlamoLanguageDefinition), | ||
typeof(FrenchAlamoLanguageDefinition), | ||
typeof(GermanAlamoLanguageDefinition), | ||
typeof(ItalianAlamoLanguageDefinition), | ||
typeof(JapaneseAlamoLanguageDefinition), | ||
typeof(KoreanAlamoLanguageDefinition), | ||
typeof(PolishAlamoLanguageDefinition), | ||
typeof(RussianAlamoLanguageDefinition), | ||
typeof(SpanishAlamoLanguageDefinition), | ||
typeof(ThaiAlamoLanguageDefinition) | ||
}; | ||
|
||
public static readonly Type DEFAULT_LANGUAGE = typeof(EnglishAlamoLanguageDefinition); | ||
} | ||
} | ||
public static readonly Type DefaultLanguage = typeof(EnglishAlamoLanguageDefinition); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 0 additions & 57 deletions
57
...arWarsGame.Localisation/PG.StarWarsGame.Localisation.Test/Util/LocalisationUtilityTest.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.