Пример #1
0
    public void Can_Dump_DataTable()
    {
        // Arrange
        var input = new[]
        {
            new MyClass {
                Name = "Person A", Age = 42
            },
            new MyClass {
                Name = "Person B with a longer name", Age = 8
            }
        };
        var sut = new DataTableDumper <MyClass>(new ColumnNameProvider <MyClass>(), new ColumnDataProvider <MyClass>());

        // Act
        var actual = sut.Dump(input);

        // Assert
        var lines = actual.GetLines();

        lines.Should().HaveCount(3);
        lines.Should().HaveElementAt(0, "| Name                        | Age |");
        lines.Should().HaveElementAt(1, "| Person A                    | 42  |");
        lines.Should().HaveElementAt(2, "| Person B with a longer name | 8   |");
    }
Пример #2
0
    public void Can_Parse_Dumped_DataTable()
    {
        // Arrange
        var input = new[]
        {
            new MyClass {
                Name = "Person|A", Age = 42
            },
        };
        var sut          = new DataTableDumper <MyClass>(new ColumnNameProvider <MyClass>(), new ColumnDataProvider <MyClass>());
        var dumpedString = sut.Dump(input);

        // Act
        var lines = dumpedString.GetLines().Skip(1).Select(x => x.UnescapePipes()).ToArray();

        // Assert
        lines.Should().HaveCount(1);
        lines.Should().HaveElementAt(0, "| Person|A | 42  |");
    }