本文整理汇总了C#中ErrorInfo.BuildMessage方法的典型用法代码示例。如果您正苦于以下问题:C# ErrorInfo.BuildMessage方法的具体用法?C# ErrorInfo.BuildMessage怎么用?C# ErrorInfo.BuildMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ErrorInfo
的用法示例。
在下文中一共展示了ErrorInfo.BuildMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildMessage_Returns_Error_Detail_Message_If_ErrorDetails_Are_Empty_Test
public void BuildMessage_Returns_Error_Detail_Message_If_ErrorDetails_Are_Empty_Test()
{
// Arrange
ErrorInfo error = new ErrorInfo(new Exception());
// Act
string detail = error.BuildMessage();
// Assert
Assert.Equal(error.Detail, detail);
}
示例2: BuildMessage_Appends_Details
public void BuildMessage_Appends_Details()
{
// Arrange
ErrorInfo error = new ErrorInfo(new Exception());
var pair = new List<KeyValuePair<string, string>>();
pair.Add(new KeyValuePair<string, string>("Key", "Value"));
error.AddDetail("Append Test", pair);
// Act
string detail = error.BuildMessage();
// Assert
Assert.True(detail.Contains("Append Test"));
}
示例3: ShouldAppend_Appender_Data_Test
public void ShouldAppend_Appender_Data_Test()
{
// Arrange
var appenders = new List<Type>
{
typeof(FirstAppender),
typeof(SecondAppender)
};
ErrorInfo error = new ErrorInfo(new Exception("Test-Exception"));
error.Appenders = appenders;
error.EnsureAppenders();
// Act
string detail = error.BuildMessage();
// Assert
Assert.True(detail.Contains("FirstAppender"));
Assert.True(detail.Contains("SecondAppender"));
Assert.True(detail.Contains("FirstKey"));
Assert.True(detail.Contains("FirstValue"));
Assert.True(detail.Contains("SecondKey"));
Assert.True(detail.Contains("SecondValue"));
}