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 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);
        }
        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);
        }
        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);
        }
Exemplo n.º 5
0
        public void SpecificIgnoreMemberUsingMap()
        {
            var property1Value = "Property1";
            var property2Value = "Property2";
            var source         = new DualPropertyClass();

            source.Property1 = property1Value;
            source.Property2 = property2Value;
            var expected =
                $"{nameof(DualPropertyClass)}{{" +
                $"{nameof(DualPropertyClass.Property1)}={property1Value}}}";
            var map    = new IgnoreMemberMap();
            var actual = map.ToString(source);

            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);
        }
        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);
        }