public void ShouldDumpObject_WithOptions_IgnoreDefaultValues()
        {
            // Arrange
            var person      = PersonFactory.GetPersonThomas();
            var dumpOptions = new DumpOptions
            {
                DumpStyle           = DumpStyle.CSharp,
                IgnoreDefaultValues = true
            };

            // Act
            var dump = ObjectDumper.Dump(person, dumpOptions);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("var person = new Person\r\n" +
                             "{\r\n" +
                             "  Name = \"Thomas\",\r\n" +
                             "  Age = 30,\r\n" +
                             "  GetOnly = 11,\r\n" +
                             "  ByteArray = new byte[]\r\n" +
                             "  {\r\n" +
                             "    1,\r\n" +
                             "    2,\r\n" +
                             "    3,\r\n" +
                             "    4\r\n" +
                             "  }\r\n" +
                             "};");
        }
Esempio n. 2
0
        public void ShouldDumpObject()
        {
            // Arrange
            var person = PersonFactory.GetPersonThomas();

            // Act
            var dump = ObjectDumperConsole.Dump(person);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("{ObjectDumping.Tests.Testdata.Person}\r\n  Name: \"Thomas\"\r\n  Char: \r\n  Age: 30\r\n  GetOnly: 11\r\n  Bool: False\r\n  Byte: 0\r\n  ByteArray: ...\r\n    1\r\n    2\r\n    3\r\n    4\r\n  SByte: 0\r\n  Float: 0\r\n  Uint: 0\r\n  Long: 0\r\n  ULong: 0\r\n  Short: 0\r\n  UShort: 0\r\n  Decimal: 0\r\n  Double: 0\r\n  DateTime: 01.01.0001 00:00:00\r\n  NullableDateTime: null\r\n  Enum: Unspecified\r\n");
        }
        public void ShouldDumpObject()
        {
            // Arrange
            var person = PersonFactory.GetPersonThomas();

            // Act
            var dump = ObjectDumperCSharp.Dump(person);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("var person = new Person\r\n{\r\n  Name = \"Thomas\",\r\n  Char = '',\r\n  Age = 30,\r\n  GetOnly = 11,\r\n  Bool = false,\r\n  Byte = 0,\r\n  ByteArray = new Byte[]\r\n  {\r\n    1,\r\n    2,\r\n    3,\r\n    4\r\n  },\r\n  SByte = 0,\r\n  Float = 0f,\r\n  Uint = 0,\r\n  Long = 0L,\r\n  ULong = 0L,\r\n  Short = 0,\r\n  UShort = 0,\r\n  Decimal = 0m,\r\n  Double = 0d,\r\n  DateTime = DateTime.MinValue,\r\n  NullableDateTime = null,\r\n  Enum = System.DateTimeKind.Unspecified\r\n};");
        }
        public void ShouldDumpObject_WithDefaultDumpOptions()
        {
            // Arrange
            var person = PersonFactory.GetPersonThomas();

            // Act
            var dump = ObjectDumper.Dump(person);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("{System.Diagnostics.Tests.Testdata.Person}\n\r  Name: \"Thomas\"\n\r  Char: \n\r  Age: 30\n\r  GetOnly: 11\n\r  Bool: False\n\r  Byte: 0\n\r  ByteArray: ...\n\r    1\n\r    2\n\r    3\n\r    4\n\r  SByte: 0\n\r  Float: 0\n\r  Uint: 0\n\r  Long: 0\n\r  ULong: 0\n\r  Short: 0\n\r  UShort: 0\n\r  Decimal: 0\n\r  Double: 0\n\r  DateTime: 01.01.0001 00:00:00\n\r  NullableDateTime: null\n\r  Enum: Unspecified\n\r");
        }
        public void ShouldDumpObject()
        {
            // Arrange
            var person = PersonFactory.GetPersonThomas();

            // Act
            var dump = ObjectDumperCSharp.Dump(person);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("var person = new Person\n\r{\n\r  Name = \"Thomas\",\n\r  Char = '',\n\r  Age = 30,\n\r  GetOnly = 11,\n\r  Bool = false,\n\r  Byte = 0,\n\r  ByteArray = new Byte[]\n\r  {\n\r    1,\n\r    2,\n\r    3,\n\r    4\n\r  },\n\r  SByte = 0,\n\r  Float = 0f,\n\r  Uint = 0,\n\r  Long = 0L,\n\r  ULong = 0L,\n\r  Short = 0,\n\r  UShort = 0,\n\r  Decimal = 0m,\n\r  Double = 0d,\n\r  DateTime = DateTime.MinValue,\n\r  NullableDateTime = null,\n\r  Enum = System.DateTimeKind.Unspecified\n\r};");
        }
Esempio n. 6
0
        public void ShouldRoslynDumpObject()
        {
            // Arrange
            var person = PersonFactory.GetPersonThomas();

            // Act
            var roslynDumper = new RoslynDumper();
            var dump         = roslynDumper.Dump(person);

            // Assert
            testOutputHelper.WriteLine(dump);

            dump.Should().NotBeNullOrWhiteSpace();
            dump.Should().Be("var person = new Person{Name = \"Thomas\", Char = '\\0', Age = 30, GetOnly = 11, Bool = false, Byte = 0, ByteArray = new Byte[]{1, 2, 3, 4}, SByte = 0, Float = 0F, Uint = 0U, Long = 0L, ULong = 0UL, Short = 0, UShort = 0, Decimal = 0M, Double = 0, DateTime = DateTime.MinValue, NullableDateTime = null, Enum = System.DateTimeKind.Unspecified};");
        }
        public void ShouldDumpObject_WithOptions()
        {
            // Arrange
            var person      = PersonFactory.GetPersonThomas();
            var dumpOptions = new DumpOptions
            {
                DumpStyle         = DumpStyle.CSharp,
                ExcludeProperties = new[] { "Name", "Char" },
                IndentChar        = ' ',
                IndentSize        = 8,
                MaxLevel          = 1,
                LineBreakChar     = "\n",
                PropertyOrderBy   = pi => pi.Name,
                SetPropertiesOnly = true
            };

            // Act
            var dump = person.Dump(dumpOptions);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("var person = new Person\n" +
                             "{\n" +
                             "        Age = 30,\n" +
                             "        Bool = false,\n" +
                             "        Byte = 0,\n" +
                             "        ByteArray = new byte[]\n" +
                             "        {\n" +
                             "        },\n" +
                             "        DateTime = DateTime.MinValue,\n" +
                             "        Decimal = 0m,\n" +
                             "        Double = 0d,\n" +
                             "        Enum = DateTimeKind.Unspecified,\n" +
                             "        Float = 0f,\n" +
                             "        Long = 0L,\n" +
                             "        NullableDateTime = null,\n" +
                             "        SByte = 0,\n" +
                             "        Short = 0,\n" +
                             "        Uint = 0u,\n" +
                             "        ULong = 0UL,\n" +
                             "        UShort = 0\n" +
                             "};");
        }
        public void ShouldDumpObject_WithDumpOptions()
        {
            // Arrange
            var person  = PersonFactory.GetPersonThomas();
            var options = new DumpOptions
            {
                IndentSize        = 1,
                IndentChar        = '\t',
                LineBreakChar     = "\n",
                SetPropertiesOnly = true
            };

            // Act
            var dump = ObjectDumperCSharp.Dump(person, options);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("var person = new Person\n{\n	Name = \"Thomas\",\n	Char = '',\n	Age = 30,\n	Bool = false,\n	Byte = 0,\n	ByteArray = new Byte[]\n	{\n		1,\n		2,\n		3,\n		4\n	},\n	SByte = 0,\n	Float = 0f,\n	Uint = 0,\n	Long = 0L,\n	ULong = 0L,\n	Short = 0,\n	UShort = 0,\n	Decimal = 0m,\n	Double = 0d,\n	DateTime = DateTime.MinValue,\n	NullableDateTime = null,\n	Enum = System.DateTimeKind.Unspecified\n};");
        }
        public void ShouldDumpObject_WithDumpStyle()
        {
            // Arrange
            var person    = PersonFactory.GetPersonThomas();
            var dumpStyle = DumpStyle.CSharp;

            // Act
            var dump = person.Dump(dumpStyle);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().Be("var person = new Person\r\n" +
                             "{\r\n" +
                             "  Name = \"Thomas\",\r\n" +
                             "  Char = '',\r\n" +
                             "  Age = 30,\r\n" +
                             "  GetOnly = 11,\r\n" +
                             "  Bool = false,\r\n" +
                             "  Byte = 0,\r\n" +
                             "  ByteArray = new byte[]\r\n" +
                             "  {\r\n" +
                             "    1,\r\n" +
                             "    2,\r\n" +
                             "    3,\r\n" +
                             "    4\r\n" +
                             "  },\r\n" +
                             "  SByte = 0,\r\n" +
                             "  Float = 0f,\r\n" +
                             "  Uint = 0u,\r\n" +
                             "  Long = 0L,\r\n" +
                             "  ULong = 0UL,\r\n" +
                             "  Short = 0,\r\n" +
                             "  UShort = 0,\r\n" +
                             "  Decimal = 0m,\r\n" +
                             "  Double = 0d,\r\n" +
                             "  DateTime = DateTime.MinValue,\r\n" +
                             "  NullableDateTime = null,\r\n" +
                             "  Enum = DateTimeKind.Unspecified\r\n" +
                             "};");
        }