goblinfactory / konsole

Home of the simple console library consisting of ProgressBar, Window, Form, Draw & MockConsole (C# console progress bar with support for single or multithreaded progress updates) Window is a 100%-ish console compatible window, supporting all normal console writing to a windowed section of the screen, supporting scrolling and clipping of console output.
721 stars 62 forks source link

Form.Write(null) throws exception #43

Closed Tr0sT closed 4 years ago

Tr0sT commented 4 years ago

new Form().Write(null); should not throw exception. Instead it should write "Null"

goblinfactory commented 4 years ago

Fixed and published - nuget.org/packages/Goblinfactory.Konsole/5.4.3. Please test and let me know if any issues.

goblinfactory commented 4 years ago
        [Test]
        public void render_null_as_NULL()
        {
            var console = new MockConsole(80, 20);
            var form = new Form(console);
            Person p = null;
            console.WriteLine("line1");
            form.Write(p);
            console.WriteLine("line2");
            var expected = new[]
            {
                "line1",
                " ┌────────────────────────────────── Person  ──────────────────────────────────┐",
                " │ Null                                                                        │",
                " └─────────────────────────────────────────────────────────────────────────────┘",
                "line2"
            };

            console.BufferWrittenTrimmed.Should().BeEquivalentTo(expected);

        }