public void TestGetTranslationsWithReplacementsTooManyParametersShouldBeIgnored() { var bundle = new ResourceBundle("FormatTags/complex", null); Assert.That(bundle.Get("onevar", new CultureInfo("en-US"), "one", "two", "three"), Is.EqualTo("the one var")); }
private static void BenchMark(string baseName, string key, int run) { var bundle = new ResourceBundle(baseName, ""); bundle.Get(key, new CultureInfo("en-US")); DateTime start = DateTime.Now; for (int i = 0; i < run; i++) { bundle.Get(key, new CultureInfo("en-US")); } DateTime end = DateTime.Now; TimeSpan time = end.Subtract(start); double avg = (run/(time.TotalMilliseconds/1000.0)); Assert.That(avg, Is.GreaterThan(run*BENCHMARK_FACTOR)); Console.WriteLine(baseName + ": " + avg + " average formats per second no model"); }
public void TestGetTranslationsWithReplacementsNonUsedParametersCanBeNull() { var bundle = new ResourceBundle("FormatTags/complex", null); Assert.That(bundle.Get("twovarswithgap", new CultureInfo("en-US"), "a", null, "c"), Is.EqualTo("two a, gap, c vars")); }
public void TestGetTranslationsWithReplacementssedParametersCanNotBeNull() { var bundle = new ResourceBundle("FormatTags/complex", null); try { bundle.Get("onevar", new CultureInfo("en-US"), null); Assert.Fail("Expected exception"); } catch (Exception e) { Assert.That(e is ArgumentNullException, Is.True); } }
public void TestGetTranslationsWithReplacements() { var bundle = new ResourceBundle("FormatTags/complex", null); Assert.That(bundle.Get("noreplacment", new CultureInfo("en-US")), Is.EqualTo("fixed")); Assert.That(bundle.Get("onevar", new CultureInfo("en-US"), "one"), Is.EqualTo("the one var")); Assert.That(bundle.Get("onevar", new CultureInfo("en-US"), 1), Is.EqualTo("the 1 var")); Assert.That(bundle.Get("twovars", new CultureInfo("en-US"), 1, 2), Is.EqualTo("two 1, 2 vars")); Assert.That(bundle.Get("twovars", new CultureInfo("en-US"), "a", "b"), Is.EqualTo("two a, b vars")); Assert.That(bundle.Get("twovars", new CultureInfo("en-US"), 1, "b"), Is.EqualTo("two 1, b vars")); Assert.That(bundle.Get("twovarswithgap", new CultureInfo("en-US"), "a", "b", "c"), Is.EqualTo("two a, gap, c vars")); }
public void TestGetTranslationsWithReplacementsMessageButNoParametersProvided() { var bundle = new ResourceBundle("FormatTags/complex", null); try { bundle.Get("onevar", new CultureInfo("en-US")); Assert.Fail("Expected exception"); } catch (Exception e) { Assert.That(e is FormatException, Is.True); } }
public void TestGetTranslationsWithPrefix() { var bundle = new ResourceBundle("FormatTags/compiled", "pre_"); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("prefixedA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("aMetVoorvoegsel")); }
public void TestGetTranslationsWithCompileWithFilePrefixFromAssembly() { var bundle = new ResourceBundle("embedded_test", null, new AssemblyBasedResourceLocator(GetType().Assembly, "FormatTags")); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("defaultA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("nederlandseA")); }
public void TestGetTranslationsWithCompile() { var bundle = new ResourceBundle("FormatTags/test", null); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("defaultA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("nederlandseA")); }
public void TestGetTranslationsOfNonExistingKey() { var bundle = new ResourceBundle("FormatTags/complex", null); Assert.That(bundle.Get("wrong", new CultureInfo("en-US")), Is.EqualTo("?wrong?")); }
public void TestGetTranslationsCompiledWithFilePrefix() { var bundle = new ResourceBundle("compiled", null, new FileBasedResourceLocator("FormatTags")); Assert.That(bundle.Get("a", new CultureInfo("en-US")), Is.EqualTo("defaultA")); Assert.That(bundle.Get("a", new CultureInfo("nl-NL")), Is.EqualTo("nederlandseA")); }