Keeps message (#79)

* Test for exception message

* Revert "Allow demystifier to add strings to existing StringBuilder (#73)"

This reverts commit 7aa753d5c7.

* Bump version
This commit is contained in:
Ben Adams
2018-11-21 15:02:45 +00:00
committed by GitHub
parent 9c2917fa47
commit cdf53b2655
9 changed files with 113 additions and 156 deletions

View File

@@ -47,5 +47,39 @@ namespace Ben.Demystifier.Test
await Task.Yield();
}
}
[Fact]
public void DemystifyKeepsMessage()
{
Exception ex = null;
try
{
throw new InvalidOperationException("aaa")
{
Data =
{
["bbb"] = "ccc",
["ddd"] = "eee",
}
};
}
catch (Exception e)
{
ex = e;
}
var original = ex.ToString();
var endLine = (int)Math.Min((uint)original.IndexOf('\n'), original.Length);
original = original.Substring(0, endLine);
var stringDemystified = ex.ToStringDemystified();
endLine = (int)Math.Min((uint)stringDemystified.IndexOf('\n'), stringDemystified.Length);
stringDemystified = stringDemystified.Substring(0, endLine);
Assert.Equal(original, stringDemystified);
}
}
}