本文整理匯總了C#中System.InvalidOperationException.ToLogString方法的典型用法代碼示例。如果您正苦於以下問題:C# InvalidOperationException.ToLogString方法的具體用法?C# InvalidOperationException.ToLogString怎麽用?C# InvalidOperationException.ToLogString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.InvalidOperationException
的用法示例。
在下文中一共展示了InvalidOperationException.ToLogString方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Exception_Message_is_included_by_default
public void Exception_Message_is_included_by_default()
{
var ex = new InvalidOperationException("oh noes!", new NullReferenceException());
var msg = ex.ToLogString();
Assert.That(msg,
Contains.Substring("oh noes!"));
}
示例2: Exception_InnerExceptions_are_included_by_default
public void Exception_InnerExceptions_are_included_by_default()
{
var ex = new InvalidOperationException("oh noes!", new NullReferenceException("oh my.", new DataException("oops!")));
Assert.That(ex.ToLogString(),
Contains.Substring("NullReferenceException"));
Assert.That(ex.ToLogString(),
Contains.Substring("DataException"));
}
示例3: Exception_Data_is_included_by_default
public void Exception_Data_is_included_by_default()
{
var ex = new InvalidOperationException("oh noes!", new NullReferenceException());
var key = "a very important int";
ex.Data[key] = 123456;
var msg = ex.ToLogString();
Assert.That(msg, Contains.Substring(key));
Assert.That(msg, Contains.Substring("123456"));
}