Making tuples pretty too

This commit is contained in:
Phil Scott
2022-02-03 22:33:45 -05:00
committed by Patrik Svensson
parent e8eb5b85b9
commit 74a2e10ff0
5 changed files with 100 additions and 27 deletions

View File

@ -35,4 +35,10 @@ public static class TestExceptions
firstFewItems = new List<T>();
throw new InvalidOperationException("Throwing!");
}
public static (string Key, List<T> Values) GetTuplesWithInnerException<T>((int First, string Second) myValue)
{
MethodThatThrows(0);
return ("key", new List<T>());
}
}

View File

@ -0,0 +1,5 @@
InvalidOperationException: Throwing!
at bool Spectre.Console.Tests.Data.TestExceptions.MethodThatThrows(int? number) in /xyz/Exceptions.cs:nn
at (string Key, List<T> Values) Spectre.Console.Tests.Data.TestExceptions.GetTuplesWithInnerException<T>((int First, string Second) myValue) in /xyz/Exceptions.cs:nn
at void Spectre.Console.Tests.Unit.ExceptionTests.<>c.<Should_Write_Exception_With_Tuple_Return>b__6_0() in /xyz/ExceptionTests.cs:nn
at Exception Spectre.Console.Tests.Unit.ExceptionTests.GetException(Action action) in /xyz/ExceptionTests.cs:nn

View File

@ -94,6 +94,21 @@ public sealed class ExceptionTests
return Verifier.Verify(result);
}
[Fact]
[Expectation("Tuple")]
public Task Should_Write_Exception_With_Tuple_Return()
{
// Given
var console = new TestConsole().Width(1024);
var dex = GetException(() => TestExceptions.GetTuplesWithInnerException<int>((0, "value")));
// When
var result = console.WriteNormalizedException(dex, ExceptionFormats.ShortenTypes);
// Then
return Verifier.Verify(result);
}
public static Exception GetException(Action action)
{
try