本文整理汇总了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"));
}