コード例 #1
0
        public void CharacterCaseFormatterTest()
        {
            CharacterCaseFormatter formatter1 = new CharacterCaseFormatter();
            string str1 = "";

            Assert.Equal(null, formatter1.Formate(str1));
            Assert.Equal(null, formatter1.Formate(null));

            string str2 = "a";

            Assert.Equal("A", formatter1.Formate(str2));

            CharacterCaseFormatter formatter2 = new CharacterCaseFormatter {
                ToUpper = false
            };

            Assert.Equal("a", formatter2.Formate(str2));

            string str3 = "A";

            Assert.Equal("a", formatter2.Formate(str3));
            Assert.Equal(null, formatter2.Formate(null));

            CharacterCaseFormatter formatter3 = new CharacterCaseFormatter {
                ToUpper = false, ValueWhenNull = "OK"
            };

            Assert.Equal("OK", formatter3.Formate(null));
            Assert.Equal("OK", formatter3.Formate(""));
        }
コード例 #2
0
        public void CharacterCaseFormatter()
        {
            var formatter1 = new CharacterCaseFormatter();
            var str1       = "";

            Assert.Equal("", formatter1.Format(str1));
            Assert.Null(formatter1.Format(null));

            var str2 = "a";

            Assert.Equal("A", formatter1.Format(str2));

            var formatter2 = new CharacterCaseFormatter {
                ToUpper = false
            };

            Assert.Equal("a", formatter2.Format(str2));

            var str3 = "A";

            Assert.Equal("a", formatter2.Format(str3));
            Assert.Null(formatter2.Format(null));

            var formatter3 = new CharacterCaseFormatter {
                ToUpper = false, Default = "OK"
            };

            Assert.Equal("OK", formatter3.Format(null));
            Assert.Equal("", formatter3.Format(""));
        }