public void Gets_default_on_missing_key() { var resourceManager = new MockResourceReaderSet { new PairSet("resources.txt") { new Pair("Test.Section.foo", "bar") } }.CreatePlainTextResourceManager(); Assert.AreEqual("bar", resourceManager.GetString("Test.Section.foo", null, "bar")); Assert.AreEqual("baz", resourceManager.GetString("Test.Section.blah", null, "baz")); }
public void GetString_falls_through_resource_culture_hierarchy() { var resourceManager = new MockResourceReaderSet { new PairSet("resources.txt") { new Pair("default", "resources") }, new PairSet("resources.custom.txt") { new Pair("custom", "resources.custom") }, new PairSet("resources.fr.txt") { new Pair("french", "resources.fr") }, new PairSet("resources.custom.fr.txt") { new Pair("custom.french", "resources.custom.fr") }, new PairSet("resources.fr-fr.txt") { new Pair("france", "resources.fr-fr") }, new PairSet("resources.custom.fr-fr.txt") { new Pair("custom.france", "resources.custom.fr-fr") }, }.CreatePlainTextResourceManager(); Assert.AreEqual("bzzz", resourceManager.GetString("unkown", new CultureInfo("fr-fr"), "bzzz")); Assert.AreEqual("resources", resourceManager.GetString("default", new CultureInfo("fr-fr"), "bzzz")); Assert.AreEqual("resources.custom", resourceManager.GetString("custom", new CultureInfo("fr-fr"), "bzzz")); Assert.AreEqual("resources.fr", resourceManager.GetString("french", new CultureInfo("fr-fr"), "bzzz")); Assert.AreEqual("resources.custom.fr", resourceManager.GetString("custom.french", new CultureInfo("fr-fr"), "bzzz")); Assert.AreEqual("resources.fr-fr", resourceManager.GetString("france", new CultureInfo("fr-fr"), "bzzz")); Assert.AreEqual("resources.custom.fr-fr", resourceManager.GetString("custom.france", new CultureInfo("fr-fr"), "bzzz")); }