using Metin2Launcher.Localization;
using Xunit;

namespace Metin2Launcher.Tests;

public class LocTests
{
    [Fact]
    public void Returns_value_for_known_key_in_cs()
    {
        Loc.SetLocale("cs");
        Assert.Equal("Hrát", Loc.Get("button.play"));
    }

    [Fact]
    public void Returns_value_for_known_key_in_en()
    {
        Loc.SetLocale("en");
        Assert.Equal("Play", Loc.Get("button.play"));
    }

    [Fact]
    public void Falls_back_to_key_for_unknown()
    {
        Loc.SetLocale("en");
        Assert.Equal("nope.does.not.exist", Loc.Get("nope.does.not.exist"));
    }

    [Fact]
    public void Format_substitutes_args()
    {
        Loc.SetLocale("en");
        Assert.Equal("Previous version 0.1.0", Loc.Get("news.previousHeader", "0.1.0"));
    }

    [Fact]
    public void Unknown_locale_falls_back_to_en()
    {
        Loc.SetLocale("xx");
        Assert.Equal("Play", Loc.Get("button.play"));
    }
}
