Пример #1
0
        public Task Should_Write_Exception()
        {
            // Given
            var console = new FakeConsole(width: 1024);
            var dex     = GetException(() => TestExceptions.MethodThatThrows(null));

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

            // Then
            return(Verifier.Verify(result));
        }
Пример #2
0
        public Task Should_Write_Exception_With_Shortened_Methods()
        {
            // Given
            var console = new TestConsole().Width(1024);
            var dex     = GetException(() => TestExceptions.MethodThatThrows(null));

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

            // Then
            return(Verifier.Verify(result));
        }
Пример #3
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");
        }
Пример #4
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");
        }