I get a full set of nested exceptions when I directly use the method ToString()on AggregateException:
public void GreenTest()
{
var ex = new AggregateException(new Exception("ex1"), new Exception("ex2"));
ex.ToString()
.Should()
.Contain("ex1")
.And
.Contain("ex2");
}
The problem is that I get only the first exception when it AggregateExceptionasserts itself in another exception:
public void RedTest()
{
var ex = new Exception("wrapper", new AggregateException(new Exception("ex1"), new Exception("ex2")));
ex.ToString()
.Should()
.Contain("wrapper")
.And
.Contain("ex1")
.And
.Contain("ex2");
}
ex2missing in the received string. Is this a bug or a known class function AggregateException?
source
share