Exemple #1
0
        public void FormatMessage_should_replace_placeholder_if_template_starts_with_it()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("{prop}bb", properties).Should().BeEquivalentTo("valuebb");
        }
Exemple #2
0
        public void FormatMessage_should_replace_placeholder_before_right_brace_when_separator_between_them_exists()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("bb{prop}cc}dd", properties).Should().BeEquivalentTo("bbvaluecc}dd");
        }
Exemple #3
0
        public void FormatMessage_should_not_ignore_case_if_props_are_not_ignorecased()
        {
            var properties = new Dictionary <string, object> {
                { "Prop", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{prop}bb", properties).Should().BeEquivalentTo("aa{prop}bb");
        }
Exemple #4
0
        public void FormatMessage_should_replace_only_deepest_placeholders()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{bb{prop}cc}dd", properties).Should().BeEquivalentTo("aa{bbvaluecc}dd");
        }
Exemple #5
0
        public void FormatMessage_should_replace_placeholders_named_like_parameters()
        {
            var properties = new Dictionary <string, object> {
                { "0", "value1" }, { "1", "value2" }
            };

            LogMessageFormatter.FormatMessage("aa{0}bb{1}cc", properties).Should().BeEquivalentTo("aavalue1bbvalue2cc");
        }
Exemple #6
0
        public void FormatMessage_should_replace_placeholder_with_tripled_braces()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("{{{prop}}}", properties).Should().BeEquivalentTo("{value}");
        }
Exemple #7
0
        public void FormatMessage_should_not_replace_placeholder_with_doubled_braces_if_template_ends_with_it()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{{prop}}", properties).Should().BeEquivalentTo("aa{prop}");
        }
Exemple #8
0
        public void FormatMessage_should_not_replace_placeholder_if_left_brace_is_doubled()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{{prop}bb", properties).Should().BeEquivalentTo("aa{prop}bb");
        }
Exemple #9
0
        public void FormatMessage_should_not_replace_placeholder_without_right_brace()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{prop", properties).Should().BeEquivalentTo("aa{prop");
        }
Exemple #10
0
        public void FormatMessage_should_work_correctly_if_template_starts_with_right_brace()
        {
            var properties = new Dictionary <string, object> {
                { "prop", "value" }
            };

            LogMessageFormatter.FormatMessage("}aa", properties).Should().BeEquivalentTo("}aa");
        }
Exemple #11
0
        public void FormatMessage_should_correctly_render_null_property_values()
        {
            var properties = new Dictionary <string, object> {
                { "prop", null }
            };

            LogMessageFormatter.FormatMessage("aa {prop} bb", properties).Should().BeEquivalentTo("aa null bb");
        }
Exemple #12
0
        public void FormatMessage_should_replace_whitespace_placeholders_if_such_key_exists_in_props()
        {
            var properties = new Dictionary <string, object> {
                { " ", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{ }bb", properties).Should().BeEquivalentTo("aavaluebb");
        }
Exemple #13
0
        public void FormatMessage_should_replace_two_placeholders_if_they_have_not_separators_between_them()
        {
            var properties = new Dictionary <string, object> {
                { "prop1", "value1" }, { "prop2", "value2" }
            };

            LogMessageFormatter.FormatMessage("{prop1}{prop2}", properties).Should().BeEquivalentTo("value1value2");
        }
Exemple #14
0
        public void FormatMessage_should_replace_two_placeholders()
        {
            var properties = new Dictionary <string, object> {
                { "prop1", "value1" }, { "prop2", "value2" }
            };

            LogMessageFormatter.FormatMessage("aa{prop1}bb{prop2}cc", properties).Should().BeEquivalentTo("aavalue1bbvalue2cc");
        }
Exemple #15
0
        public void FormatMessage_should_ignore_case_if_props_are_ignorecased()
        {
            var properties = new Dictionary <string, object>(StringComparer.CurrentCultureIgnoreCase)
            {
                { "Prop", "value" }
            };

            LogMessageFormatter.FormatMessage("aa{prop}bb", properties).Should().BeEquivalentTo("aavaluebb");
        }
Exemple #16
0
 public void FormatMessage_should_produce_repeatable_results()
 {
     for (var i = 0; i < 100; i++)
     {
         LogMessageFormatter.FormatMessage("aa{prop}bb", new Dictionary <string, object> {
             { "prop", "_" }
         })
         .Should().BeEquivalentTo("aa_bb");
     }
 }
 public void Render(LogEvent @event, TextWriter writer) =>
 writer.Write(LogMessageFormatter.FormatMessage(@event.MessageTemplate, @event.Properties));
Exemple #18
0
 public void FormatMessage_should_return_template_for_null_properties()
 {
     LogMessageFormatter.FormatMessage("aa{prop}bb", null).Should().BeEquivalentTo("aa{prop}bb");
 }
Exemple #19
0
 public void FormatMessage_should_return_empty_string_for_empty_template()
 {
     LogMessageFormatter.FormatMessage("", new Dictionary <string, object>()).Should().BeEmpty();
 }
Exemple #20
0
 public void FormatMessage_should_return_null_for_null_template()
 {
     LogMessageFormatter.FormatMessage(null, new Dictionary <string, object>()).Should().BeNull();
 }