public void Format_Color_ARGB() { var formatter = CustomFormatter.Default().Add <DecimalColorFormatter>(); var text = string.Format(formatter, "{0:ARGB}", Color.DarkRed); Assert.AreEqual("255, 139, 0, 0", text); }
public void Format_String_Lower() { var formatter = CustomFormatter.Default().Add <CaseFormatter>(); var text = string.Format(formatter, "foo {0:tolower} baz", "BAR"); Assert.AreEqual("foo bar baz", text); }
public void Format_CurlyBraces_CurlyBraces() { var formatter = CustomFormatter.Default().Add <BracketFormatter>(); var text = string.Format(formatter, "foo {0:curly} bar", 20); Assert.AreEqual("foo {20} bar", text); }
public void Format_Color_0xARGB() { var formatter = CustomFormatter.Default().Add <HexadecimalColorFormatter>(); var text = string.Format(formatter, "{0:0xARGB}", Color.DarkRed); Assert.AreEqual("FF8B0000", text); }
public void Format_String_Upper() { var formatter = CustomFormatter.Default().Add <CaseFormatter>(); var text = string.Format(formatter, "foo {0:upper} baz", "bar"); var formattedText = "foo BAR baz"; Assert.AreEqual(formattedText, text); }
public void Format_SquareBrackets_SquareBrackets() { var formatter = CustomFormatter.Default().Add <BracketFormatter>(); var text = string.Format(formatter, "foo {0:square} bar", 20); var formattedText = "foo [20] bar"; Assert.AreEqual(formattedText, text); }
public void AllFormats() { var formatter = CustomFormatter.Default() .Add <CaseFormatter>() .Add <BracketFormatter>() .Add <QuoteFormatter>() .Add <DecimalColorFormatter>() .Add <HexadecimalColorFormatter>(); var text = "foo {a:double} {b:square} {c:u}".Format(new { a = "bar", b = "baz", c = "qux" }, formatter); Assert.AreEqual("foo \"bar\" [baz] QUX", text); }
public void Format_Int32_String() { var formatter = CustomFormatter.Default(); Assert.AreEqual("foo ' 32' bar", string.Format(formatter, "foo '{0,4}' bar", 32)); }