// //
// // Licensed under the MIT License. See LICENSE file in the project root for full license information.
// //
namespace MUnique.OpenMU.Tests;
using System;
using System.Globalization;
using MUnique.OpenMU.DataModel;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.DataModel.Entities;
///
/// Unit tests for verifying that returns expected captions and descriptions
/// for types, properties and enum values, including fallbacks for unknown languages and types.
///
[TestFixture]
public class ModelResourcesTest
{
///
/// Verifies that returns the expected caption
/// for in English culture.
///
[Test]
public void TypeCaption()
{
var typeName = ModelResourceProvider.GetTypeCaption(CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo("Area Skill Settings"));
}
///
/// Verifies that returns the pluralized caption
/// for in English culture.
///
[Test]
public void TypeCaptionPlural()
{
var typeName = ModelResourceProvider.GetPluralizedTypeCaption(CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo("Accounts"));
}
///
/// Verifies that returns the expected (empty) description
/// for in English culture.
///
[Test]
public void TypeDescription()
{
var typeName = ModelResourceProvider.GetTypeDescription(CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo(""));
}
///
/// Verifies that returns a humanized caption
/// for the property .
///
[Test]
public void PropertyCaption()
{
var typeName = ModelResourceProvider.GetPropertyCaption(nameof(AreaSkillSettings.DelayBetweenHits), CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo("Delay Between Hits"));
}
///
/// Verifies that a caption can be retrieved for a property inherited from a base type,
/// here .
///
[Test]
public void InheritedPropertyCaption()
{
var typeName = ModelResourceProvider.GetPropertyCaption(nameof(ExitGate.X1), CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo("X1"));
}
///
/// Verifies that returns the expected (empty) description
/// for property .
///
[Test]
public void PropertyDescription()
{
var typeName = ModelResourceProvider.GetPropertyDescription(nameof(AreaSkillSettings.DelayBetweenHits), CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo(""));
}
///
/// Verifies that an unknown language (Swahili here) falls back to a default caption for a known type.
///
[Test]
public void TypeCaptionUnknownLanguage()
{
var typeName = ModelResourceProvider.GetTypeCaption(CultureInfo.GetCultureInfo("sw"));
Assert.That(typeName, Is.EqualTo("Area Skill Settings"));
}
///
/// Verifies that unknown types get a humanized caption from their type name (splitting PascalCase).
///
[Test]
public void TypeCaptionUnknownType()
{
var typeName = ModelResourceProvider.GetTypeCaption(CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo("Model Resources Test"));
}
///
/// Verifies that an unknown type and property name gets a humanized caption (PascalCase splitting).
///
[Test]
public void PropertyCaptionUnknownTypeAndProperty()
{
var typeName = ModelResourceProvider.GetPropertyCaption("FooBar", CultureInfo.GetCultureInfo("en"));
Assert.That(typeName, Is.EqualTo("Foo Bar"));
}
///
/// Verifies that the generic overload of
/// returns the expected caption for an enum value.
///
[Test]
public void EnumCaptionGeneric()
{
var caption = ModelResourceProvider.GetEnumCaption(AccountState.GameMaster, CultureInfo.GetCultureInfo("en"));
Assert.That(caption, Is.EqualTo("Game Master"));
}
///
/// Verifies that the non-generic overload of
/// returns the expected caption for an enum value.
///
[Test]
public void EnumCaption()
{
var caption = ModelResourceProvider.GetEnumCaption(typeof(AccountState), AccountState.GameMaster, CultureInfo.GetCultureInfo("en"));
Assert.That(caption, Is.EqualTo("Game Master"));
}
}