public override string ToString()
            {
                var builder = new ToStringBuilder($"[ETag: `{ETag}']");

                if (TransactionSampleRate.HasValue)
                {
                    builder.Add(nameof(TransactionSampleRate), TransactionSampleRate.Value);
                }

                return(builder.ToString());
            }
        public void ProcessNullProperty()
        {
            string property1Value = null;
            var    source         = new SinglePropertyClass()
            {
                Property1 = property1Value
            };
            var expected = $"{nameof(SinglePropertyClass)}{{{nameof(SinglePropertyClass.Property1)}={string.Empty}}}";
            var actual   = ToStringBuilder.ToString(source);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
示例#3
0
        public void ToStringAppendNull()
        {
            // setup
            var dictionaryContainer = new DictionaryContainer();
            var toStringBuilder     = new ToStringBuilder <DictionaryContainer>(dictionaryContainer);

            // test
            toStringBuilder.Append(null, "NullName");
            var toString = toStringBuilder.ToString();

            // assert
            Assert.AreEqual("DictionaryContainer:{NullName=null}", toString);
        }
示例#4
0
        public string toString()
        {
            ToStringBuilder <AbstractRegisteredService> toStringBuilder = new ToStringBuilder <AbstractRegisteredService>(this);

            toStringBuilder.Append(x => x.id);
            toStringBuilder.Append(x => x.name);
            toStringBuilder.Append(x => x.description);
            toStringBuilder.Append(x => x.serviceId);
            toStringBuilder.Append(x => x.usernameAttribute);
            toStringBuilder.Append(x => x.allowedAttributes.ToArray());

            return(toStringBuilder.ToString());
        }
示例#5
0
        public override string ToString()
        {
            var resultBuilder = new ToStringBuilder(nameof(MetricSetDto));

            resultBuilder.Add("Timestamp", Timestamp);
            var samplesToStringBuilder = new ToStringBuilder("");

            foreach (var sample in Samples)
            {
                resultBuilder.Add(sample.Key, sample.Value);
            }
            resultBuilder.Add("samples", samplesToStringBuilder.ToString());
            return(resultBuilder.ToString());
        }
        public void ProcessOneFieldClass()
        {
            var field1Value = "Field1";
            var source      = new SingleFieldClass();

            source.Field1 = field1Value;
            var expected = $"{nameof(SingleFieldClass)}{{{nameof(SingleFieldClass.Field1)}={field1Value}}}";
            var config   = new ToStringConfig <SingleFieldClass>();

            config.OutputTarget = TargetType.Both;
            var actual = ToStringBuilder.ToString(source, config);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
        public void IgnoreWhiteSpaceProperty()
        {
            var source = new DualPropertyClass()
            {
                Property1 = " ", Property2 = null
            };
            var config = new ToStringConfig <DualPropertyClass>()
            {
                IgnoreMode = IgnoreMemberMode.NullOrWhiteSpace
            };
            var expected = $"{nameof(DualPropertyClass)}{{}}";
            var actual   = ToStringBuilder.ToString(source, config);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
        public void ProcessDualPropertyClass()
        {
            var property1Value = "Property1";
            var property2Value = "Property2";
            var source         = new DualPropertyClass()
            {
                Property1 = property1Value, Property2 = property2Value
            };
            var expected =
                $"{nameof(DualPropertyClass)}{{" +
                $"{nameof(DualPropertyClass.Property1)}={property1Value}," +
                $"{nameof(DualPropertyClass.Property2)}={property2Value}}}";
            var actual = ToStringBuilder.ToString(source);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
        public void IgnoreNullProperty()
        {
            var property1Value = " ";
            var source         = new DualPropertyClass()
            {
                Property1 = property1Value, Property2 = null
            };
            var config = new ToStringConfig <DualPropertyClass>()
            {
                IgnoreMode = IgnoreMemberMode.Null
            };
            var expected = $"{nameof(DualPropertyClass)}{{{nameof(DualPropertyClass.Property1)}={property1Value}}}";
            var actual   = ToStringBuilder.ToString(source, config);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
示例#10
0
        public void OutputProperty()
        {
            var property1Value = "Property1";
            var field1Value    = "Field1";
            var source         = new PropertyAndFieldClass()
            {
                Property = property1Value
            };

            source.Field = field1Value;
            var expected =
                $"{nameof(PropertyAndFieldClass)}{{" +
                $"{nameof(PropertyAndFieldClass.Property)}={property1Value}}}";
            var actual = ToStringBuilder.ToString(source);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
        public void IgnoreStaticMember()
        {
            var staticPropertyValue = "StaticProperty";
            var property1Value      = "Property1";

            HasStaticMemberClass.StaticProperty1 = staticPropertyValue;
            var source = new HasStaticMemberClass()
            {
                Property1 = property1Value
            };
            var expected =
                $"{nameof(HasStaticMemberClass)}{{" +
                $"{nameof(HasStaticMemberClass.Property1)}={property1Value}}}";
            var actual = ToStringBuilder.ToString(source);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
        public void IgnoreSpecifiedProperty()
        {
            var property1Value = "Property1";
            var property2Value = "Property2";
            var source         = new DualPropertyClass()
            {
                Property1 = property1Value, Property2 = property2Value
            };
            var expected =
                $"{nameof(DualPropertyClass)}{{" +
                $"{nameof(DualPropertyClass.Property1)}={property1Value}}}";
            var config = new ToStringConfig <DualPropertyClass>();

            config.SetIgnoreMember(it => it.Property2);
            var actual = ToStringBuilder.ToString(source, config);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
示例#13
0
        public void OutputField()
        {
            var property1Value = "Property1";
            var field1Value    = "Field1";
            var source         = new PropertyAndFieldClass()
            {
                Property = property1Value
            };

            source.Field = field1Value;
            var expected =
                $"{nameof(PropertyAndFieldClass)}{{" +
                $"{nameof(PropertyAndFieldClass.Field)}={field1Value}}}";
            var config = new ToStringConfig <PropertyAndFieldClass>()
            {
                OutputTarget = TargetType.Field
            };
            var actual = ToStringBuilder.ToString(source, config);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
示例#14
0
            public override string ToString()
            {
                var builder = new ToStringBuilder($"[ETag: `{ETag}']");

                if (CaptureBody != null)
                {
                    builder.Add(nameof(CaptureBody), CaptureBody);
                }
                if (CaptureBodyContentTypes != null)
                {
                    builder.Add(nameof(CaptureBodyContentTypes), string.Join(", ", CaptureBodyContentTypes.Select(x => $"`{x}'")));
                }
                if (TransactionMaxSpans.HasValue)
                {
                    builder.Add(nameof(TransactionMaxSpans), TransactionMaxSpans.Value);
                }
                if (TransactionSampleRate.HasValue)
                {
                    builder.Add(nameof(TransactionSampleRate), TransactionSampleRate.Value);
                }

                return(builder.ToString());
            }
示例#15
0
 public override string ToString()
 => ToStringBuilder.ToString(IdentityFields());
 public override string ToString()
 {
     return(ToStringBuilder.ToString(this));
 }
示例#17
0
 public override string ToString() => ToStringBuilder.ToString(Reflect());
        public string toString()
        {
            ToStringBuilder<AbstractRegisteredService> toStringBuilder = new ToStringBuilder<AbstractRegisteredService>(this);
            toStringBuilder.Append(x => x.id);
            toStringBuilder.Append(x => x.name);
            toStringBuilder.Append(x => x.description);
            toStringBuilder.Append(x => x.serviceId);
            toStringBuilder.Append(x => x.usernameAttribute);
            toStringBuilder.Append(x => x.allowedAttributes.ToArray());

            return toStringBuilder.ToString();
        }