package de.siphalor.was;

import de.siphalor.was.content.ContentManager;
import de.siphalor.was.content.lang.Lang;
import de.siphalor.was.dummy.DummyContentPack;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;

public class I18nTests {
	static ContentManager contentManager;
	static DummyContentPack contentPack;
	static Lang lang;

	@BeforeAll
	public static void prepareAll() {
		contentManager = new ContentManager();
		contentPack = new DummyContentPack("dummy");
		contentManager.addPack(contentPack);
		contentPack.content.put("lang/dummy.properties", "abc = missingno\nescaped = \\\\\na.b.c = noop\nformatted = Formatted: %s!\nunicode = \\u20ac");
		lang = new Lang("dummy");
		lang.load(contentManager);
	}

	@Test
	public void basicTest() {
		Assertions.assertEquals("missingno", lang.get("abc"));
		Assertions.assertEquals("noop", lang.get("a.b.c"));
		Assertions.assertEquals("\\", lang.get("escaped"));
	}

	@Test
	public void unicodeTest() {
		Assertions.assertEquals("\u20ac", lang.get("unicode"), "Failed to resolve unicode in lang file");
	}
}
