Ejemplo n.º 1
0
        public void Should_Write_Exception_With_Shortened_Methods()
        {
            // Given
            var console = new PlainConsole(width: 1024);
            var dex     = GetException(() => TestExceptions.MethodThatThrows(null));

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

            // Then
            result.Length.ShouldBe(4);
            result[0].ShouldBe("System.InvalidOperationException: Throwing!");
            result[1].ShouldBe("  at MethodThatThrows(Nullable`1 number) in /xyz/Exceptions.cs:nn");
            result[2].ShouldBe("  at <Should_Write_Exception_With_Shortened_Methods>b__2_0() in /xyz/ExceptionTests.cs:nn");
            result[3].ShouldBe("  at GetException(Action action) in /xyz/ExceptionTests.cs:nn");
        }
Ejemplo n.º 2
0
        public void Should_Write_Exception()
        {
            // Given
            var console = new PlainConsole(width: 1024);
            var dex     = GetException(() => TestExceptions.MethodThatThrows(null));

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

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