Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Commit cfec4f1

Browse files
committed
Add line break method to the message builder.
1 parent a4feb49 commit cfec4f1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/SymphonyOSS.RestApiClient/MessageML/MessageBuilder.cs

+11
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,17 @@ public MessageBuilder Link(string href)
139139
return this;
140140
}
141141

142+
/// <summary>
143+
/// Appends a line break.
144+
/// </summary>
145+
/// <returns>Itself to allow for chaining.</returns>
146+
public MessageBuilder NewLine()
147+
{
148+
var xmlElement = _xmlDocument.CreateElement("br");
149+
_rootElement.AppendChild(xmlElement);
150+
return this;
151+
}
152+
142153
/// <summary>
143154
/// Constructs the string representation of this message.
144155
/// </summary>

test/SymphonyOSS.RestApiClient.Tests/MessageBuilderTest.cs

+11
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,16 @@ public void EnsureMentions_are_inserted()
6767
.ToString();
6868
Assert.Equal("<messageML><mention uid=\"12345\" /><mention email=\"[email protected]\" /></messageML>", emptyMessage);
6969
}
70+
71+
[Fact]
72+
public void EnsureNewLine_is_inserted()
73+
{
74+
var emptyMessage = new MessageBuilder()
75+
.Text("line 1")
76+
.NewLine()
77+
.Text("line 2")
78+
.ToString();
79+
Assert.Equal("<messageML>line 1<br />line 2</messageML>", emptyMessage);
80+
}
7081
}
7182
}

0 commit comments

Comments
 (0)