예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
        public void Format_Color_0xARGB()
        {
            var formatter = CustomFormatter.Default().Add <HexadecimalColorFormatter>();

            var text = string.Format(formatter, "{0:0xARGB}", Color.DarkRed);

            Assert.AreEqual("FF8B0000", text);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        public void Format_Int32_String()
        {
            var formatter = CustomFormatter.Default();

            Assert.AreEqual("foo '  32' bar", string.Format(formatter, "foo '{0,4}' bar", 32));
        }