C# 使用Owin TestServer时返回的异常未完成

C# 使用Owin TestServer时返回的异常未完成,c#,asp.net-web-api,asp.net-web-api2,owin,C#,Asp.net Web Api,Asp.net Web Api2,Owin,我有一个web api,我想测试它。当我使用browser调用它时,它会返回一个json,如: { message: "An error has occurred.", exceptionMessage: "Self referencing loop detected with type ......", exceptionType: "Newtonsoft.Json.JsonSerializationException", stackTrace: " at Ne

我有一个web api,我想测试它。当我使用browser调用它时,它会返回一个json,如:

{
    message: "An error has occurred.",
    exceptionMessage: "Self referencing loop detected with type ......",
    exceptionType: "Newtonsoft.Json.JsonSerializationException",
    stackTrace: " at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CheckForCircularReference(JsonWriter writer, Object value, JsonProperty property, JsonContract contract, JsonContainerContract containerContract, JsonProperty containerProperty) 
                    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) 
                    at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty) 
                    "
}
但当我在单元测试中使用Owin
TestServer
调用它时,它只返回一个简单的json,没有所有细节:

{
    message: "An error has occurred."
}
在我的单元测试中,我这样调用api:

var response = OwinServer.HttpClient.GetAsync("api/Products/GetAll").Result;
if (response.StatusCode != HttpStatusCode.OK)
{
    var errorStr = response.Content.ReadAsStringAsync().Result;
    Assert.Fail(errorStr)   // this errorStr is not complete enough!
}
如果出现完全错误,特别是堆栈跟踪,我该怎么办