本文整理匯總了C#中System.Result.AddMessage方法的典型用法代碼示例。如果您正苦於以下問題:C# Result.AddMessage方法的具體用法?C# Result.AddMessage怎麽用?C# Result.AddMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Result
的用法示例。
在下文中一共展示了Result.AddMessage方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddMessage_Always_ShouldAddMessageToList
public void AddMessage_Always_ShouldAddMessageToList()
{
// Arrange
var result = new Result();
var originalMessage = "the original message";
result.Message = originalMessage;
var newMessage = "new message";
// Act
result.AddMessage( newMessage );
// Assert
Assert.AreEqual( 2, result.GetMessages().Count() );
Assert.AreEqual( originalMessage, result.GetMessages().ElementAt( 0 ) );
Assert.AreEqual( newMessage, result.GetMessages().ElementAt( 1 ) );
}
示例2: MessageGet_GivenListOfMessages_ShouldReturnMessagesOnMultipleLines
public void MessageGet_GivenListOfMessages_ShouldReturnMessagesOnMultipleLines()
{
// Arrange
var result = new Result();
string firstMessage = "first message";
string secondMessage = "second message";
result.AddMessage( firstMessage );
result.AddMessage( secondMessage );
// Act
var message = result.Message;
// Assert
var splitMessage = message.Split(
new[] { Environment.NewLine },
StringSplitOptions.RemoveEmptyEntries );
Assert.AreEqual( firstMessage, splitMessage[0] );
Assert.AreEqual( secondMessage, splitMessage[01] );
}
示例3: GetMessages_Always_ReturnsMessageList
public void GetMessages_Always_ReturnsMessageList()
{
// Arrange
var result = new Result();
var firstMessage = "first message";
var secondMessage = "second message";
result.AddMessage( firstMessage );
result.AddMessage( secondMessage );
// Act
var messages = result.GetMessages().ToList();
// Asset
Assert.AreEqual( 2, messages.Count() );
Assert.AreEqual( firstMessage, messages.ElementAt( 0 ) );
Assert.AreEqual( secondMessage, messages.ElementAt( 1 ) );
}