Files
jobtrackingapp/JobTrackerApi.Tests/HumanLanguageCatalogTests.cs
T
2026-08-27 15:27:48 +02:00

66 lines
2.4 KiB
C#

using JobTrackerApi.Models;
using Xunit;
namespace JobTrackerApi.Tests;
// The catalog used to be built solely from CultureInfo.GetCultures, so which languages it
// recognised depended on the host's ICU data: 806 cultures on a normal machine, exactly 1
// under globalization-invariant mode. CV imports silently lost their Languages section on a
// container with trimmed or absent ICU data, and every existing test still passed locally.
//
// These pin the explicitly seeded catalog, so deleting the seed list fails here rather than
// in production on a machine nobody tested.
public sealed class HumanLanguageCatalogTests
{
[Theory]
[InlineData("English")]
[InlineData("Norwegian")]
[InlineData("French")]
[InlineData("Spanish")]
[InlineData("German")]
[InlineData("Arabic")]
[InlineData("Chinese")]
[InlineData("Polish")]
public void Common_languages_resolve_without_relying_on_host_culture_data(string language)
{
Assert.Equal(language, HumanLanguageCatalog.NormalizeLanguageName(language));
}
[Theory]
[InlineData("norsk")]
[InlineData("bokmål")]
[InlineData("nynorsk")]
public void Norwegian_aliases_resolve_to_the_canonical_name(string alias)
{
Assert.Equal("Norwegian", HumanLanguageCatalog.NormalizeLanguageName(alias));
}
[Fact]
public void Norwegian_cv_terms_normalize_without_changing_the_canonical_storage_language()
{
Assert.Equal("English", HumanLanguageCatalog.NormalizeLanguageName("engelsk"));
Assert.Equal("Native", HumanLanguageCatalog.ExtractLevel("morsmål"));
Assert.Equal("Professional working proficiency", HumanLanguageCatalog.ExtractLevel("profesjonelt arbeidsnivå"));
}
[Theory]
[InlineData("C#")]
[InlineData("Leadership")]
[InlineData("Public speaking")]
[InlineData("Go")] // a programming language, not a human one
[InlineData("Java")] // Javanese is a language; Java is not
[InlineData("Swift")]
[InlineData("Rust")]
public void Technical_skills_are_not_treated_as_human_languages(string skill)
{
Assert.Null(HumanLanguageCatalog.NormalizeLanguageName(skill));
}
[Fact]
public void A_language_embedded_in_a_phrase_is_extracted_with_its_level()
{
Assert.Equal("Norwegian", HumanLanguageCatalog.NormalizeLanguageName("Native Norwegian speaker"));
Assert.Equal("Native", HumanLanguageCatalog.ExtractLevel("Native Norwegian speaker"));
}
}