DTLib.Demystifier/test/Ben.Demystifier.Test/ToDemystifiedStringTests.cs
Sergey Teplyakov 125e373b45 Remove the dependency on System.ValueTuple (#63)
* Add an option to get tuple data via reflection.

* Removed non-relfection-based way of getting information about the tuples.

* Make methods static back.

* Remove the nuget dependency to System.ValueTuple
2018-02-23 11:24:41 +00:00

52 lines
1.3 KiB
C#

using System;
using System.Diagnostics;
using System.Threading.Tasks;
using Xunit;
using Xunit.Abstractions;
namespace Ben.Demystifier.Test
{
public sealed class ToDemystifiedStringTests
{
private readonly ITestOutputHelper _output;
public ToDemystifiedStringTests(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void DemystifyShouldNotAffectTheOriginalStackTrace()
{
try
{
SimpleMethodThatThrows(null).Wait();
}
catch (Exception e)
{
var original = e.ToString();
var stringDemystified = e.ToStringDemystified();
_output.WriteLine("Demystified: ");
_output.WriteLine(stringDemystified);
_output.WriteLine("Original: ");
var afterDemystified = e.ToString();
_output.WriteLine(afterDemystified);
Assert.Equal(original, afterDemystified);
}
async Task SimpleMethodThatThrows(string value)
{
if (value == null)
{
throw new InvalidOperationException("message");
}
await Task.Yield();
}
}
}
}