コード例 #1
0
        public void OutputBoth()
        {
            var property1Value = "Property1";
            var field1Value    = "Field1";
            var source         = new PropertyAndFieldClass()
            {
                Property = property1Value
            };

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

            ;
            var config = new ToStringConfig <PropertyAndFieldClass>()
            {
                OutputTarget = TargetType.Both
            };
            var actual = ToStringBuilder.ToString(source, config);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #2
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);
        }
コード例 #3
0
        public void BasicMapping()
        {
            var propertyValue = "Property";
            var fieldValue    = "Field";
            var source        = new PropertyAndFieldClass();

            source.Property = propertyValue;
            source.Field    = fieldValue;
            var expected =
                $"{nameof(PropertyAndFieldClass)}{{" +
                $"{nameof(PropertyAndFieldClass.Property)}={propertyValue}," +
                $"{nameof(PropertyAndFieldClass.Field)}={fieldValue}}}";
            var map    = new PropertyAndFieldClassMap();
            var actual = map.ToString(source);

            Console.WriteLine(actual);
            Assert.AreEqual(expected, actual);
        }
コード例 #4
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);
        }
コード例 #5
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);
        }