예제 #1
0
    public Task Should_Write_Exception_With_Inner_Exception()
    {
        // Given
        var console = new TestConsole().Width(1024);
        var dex     = GetException(() => TestExceptions.ThrowWithInnerException());

        // When
        var result = console.WriteNormalizedException(dex);

        // Then
        return(Verifier.Verify(result));
    }
예제 #2
0
        public void Should_Write_Exception_With_Inner_Exception()
        {
            // Given
            var console = new PlainConsole(width: 1024);
            var dex     = GetException(() => TestExceptions.ThrowWithInnerException());

            // When
            var result = console.WriteExceptionAndGetLines(dex);

            // Then
            result.Length.ShouldBe(7);
            result[0].ShouldBe("System.InvalidOperationException: Something threw!");
            result[1].ShouldBe("     System.InvalidOperationException: Throwing!");
            result[2].ShouldBe("       at Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn");
            result[3].ShouldBe("       at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn");
            result[4].ShouldBe("  at Spectre.Console.Tests.Data.TestExceptions.ThrowWithInnerException() in /xyz/Exceptions.cs:nn");
            result[5].ShouldBe("  at Spectre.Console.Tests.Unit.ExceptionTests.<>c.<Should_Write_Exception_With_Inner_Exception>b__3_0() in /xyz/ExceptionTests.cs:nn");
            result[6].ShouldBe("  at Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn");
        }