Exemplo n.º 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);
        }
        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 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);
        }
Exemplo n.º 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);
        }
        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);
        }