public void Event_and_property_has_different_Prefix()
        {
            var evt = new LogEventInfo("Test", "App")
            {
                Properties =
                {
                    ["Props.Prop1"] = "Value1"
                }
            };
            var expected = new Dictionary <string, string> {
                ["App.Props.Prop1"] = "Value1"
            };

            Assert.That(evt.GetQualifiedProperties(), Is.EquivalentTo(expected));
        }
        public void One_no_Prefix()
        {
            var evt = new LogEventInfo("Test")
            {
                Properties =
                {
                    ["Prop1"] = "Value1"
                }
            };
            var expected = new Dictionary <string, string> {
                ["Prop1"] = "Value1"
            };

            Assert.That(evt.GetQualifiedProperties(), Is.EquivalentTo(expected));
        }
Exemplo n.º 3
0
        public string Serialize(LogEventInfo source)
        {
            if (!source.HasMetric && !source.HasProperty)
            {
                return(String.Format(FieldTemplate, EventFieldName, source.FullName));
            }

            var properties   = source.GetQualifiedProperties();
            var metrics      = source.GetQualifiedMetrics();
            int elementCount = GetPropertyAndMetricCount(properties, metrics);
            var sb           = new StringBuilder(1 + elementCount * 50);

            sb.AppendFormat(FieldTemplate, EventFieldName, source.FullName);
            WriteCollection(properties, sb);
            WriteCollection(metrics, sb);
            return(sb.ToString());
        }