[smuxi/experiments/certfp: 24/55] Engine(-Tests): applied coding standards
- From: Mirco M. M. Bauer <mmmbauer src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [smuxi/experiments/certfp: 24/55] Engine(-Tests): applied coding standards
- Date: Sun, 12 Jan 2014 07:28:11 +0000 (UTC)
commit 7590c91900926e86ea27e24ded3ec48226687d6a
Author: Mirco Bauer <meebey meebey net>
Date: Fri Jan 3 03:51:59 2014 +0100
Engine(-Tests): applied coding standards
src/Engine-Tests/MessageBuilderTests.cs | 25 +++++++++++++------------
src/Engine/Messages/MessageBuilder.cs | 27 +++++++++++++--------------
2 files changed, 26 insertions(+), 26 deletions(-)
---
diff --git a/src/Engine-Tests/MessageBuilderTests.cs b/src/Engine-Tests/MessageBuilderTests.cs
index 448d2fd..ce5f2be 100644
--- a/src/Engine-Tests/MessageBuilderTests.cs
+++ b/src/Engine-Tests/MessageBuilderTests.cs
@@ -309,7 +309,7 @@ namespace Smuxi.Engine
var builder = new MessageBuilder();
builder.AppendFormat("{{{{virtual {0}}}}}", "hugs");
}
-
+
void TestMessage(string message, MessageModel expectedMsg)
{
var builder = new MessageBuilder();
@@ -318,7 +318,7 @@ namespace Smuxi.Engine
var actualMsg = builder.ToMessage();
Assert.AreEqual(expectedMsg, actualMsg);
}
-
+
[Test]
public void AppendTextUrlParsingSanity()
{
@@ -340,7 +340,7 @@ namespace Smuxi.Engine
var msg = @"This is a http://sentence.that/ends.with?a. This is another sentence.";
*/
}
-
+
[Test]
public void AppendTextUrlParsingLtGtBrackets()
{
@@ -353,6 +353,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel(">"));
TestMessage(msg, builder.ToMessage());
}
+
[Test]
public void AppendTextUrlParsingUrlEndsInComma()
{
@@ -365,7 +366,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel(", it is really cool"));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlParsingUrlNoProtocol()
{
@@ -378,7 +379,7 @@ namespace Smuxi.Engine
builder.Append(new UrlMessagePartModel(url, urltext));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlParsingEndsInQuestionmark()
{
@@ -401,7 +402,7 @@ namespace Smuxi.Engine
var msg = @"This is a http://sentence.that/ends.with?a. This is another sentence.";
*/
}
-
+
[Test]
public void AppendTextUrlParsingUrlInBrackets()
{
@@ -414,7 +415,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel(") has nothing on it"));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlGithubMessage()
{
@@ -426,7 +427,7 @@ namespace Smuxi.Engine
builder.Append(new UrlMessagePartModel(url));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlSquareBrackets()
{
@@ -439,7 +440,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel("] and fossevents "));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlNormalBrackets()
{
@@ -452,7 +453,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel("). Thank you for usin"));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlMultipleInQuotes()
{
@@ -466,7 +467,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel(@""" ext=""voice-v1 camera-v1 video-v1""
ver=""AcN1/PEN8nq7AHD+9jpxMV4U6YM="" />"));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlEndsInClosedBracket()
{
@@ -478,7 +479,7 @@ namespace Smuxi.Engine
builder.Append(new TextMessagePartModel(@")"));
TestMessage(msg, builder.ToMessage());
}
-
+
[Test]
public void AppendTextUrlEndsInDot()
{
diff --git a/src/Engine/Messages/MessageBuilder.cs b/src/Engine/Messages/MessageBuilder.cs
index bfae7be..7075f2c 100644
--- a/src/Engine/Messages/MessageBuilder.cs
+++ b/src/Engine/Messages/MessageBuilder.cs
@@ -859,17 +859,17 @@ namespace Smuxi.Engine
public static IList<MessagePartModel> ParseSmartLinks(TextMessagePartModel textPart,
List<MessageBuilderSettings.SmartLink> links)
{
- IList<MessagePartModel> msg = new List<MessagePartModel>();
+ var msgParts = new List<MessagePartModel>();
if (links.Count == 0) {
// all smartlinks have been tried -> this text is PURE text
- msg.Add(textPart);
- return msg;
+ msgParts.Add(textPart);
+ return msgParts;
}
var subLinks = new List<MessageBuilderSettings.SmartLink>(links);
- MessageBuilderSettings.SmartLink link = subLinks.First();
+ var link = subLinks.First();
subLinks.Remove(link);
- Match linkMatch = link.MessagePartPattern.Match(textPart.Text);
+ var linkMatch = link.MessagePartPattern.Match(textPart.Text);
if (!linkMatch.Success) {
// no smartlinks in this MessagePart, try other smartlinks
return ParseSmartLinks(textPart, subLinks);
@@ -893,20 +893,19 @@ namespace Smuxi.Engine
if (link.TextFormat != null) {
text = String.Format(link.TextFormat, groupValues);
} else {
- text = (linkMatch.Value == url)?null:linkMatch.Value;
+ text = (linkMatch.Value == url) ? null : linkMatch.Value;
}
-
-
+
if (lastindex != linkMatch.Index) {
// there were some non-url-chars before this url
// copy TextMessagePartModel
- TextMessagePartModel notLinkPart = new TextMessagePartModel(textPart);
+ var notLinkPart = new TextMessagePartModel(textPart);
// only take the proper chunk of text
- notLinkPart.Text = textPart.Text.Substring(lastindex, linkMatch.Index-lastindex);
+ notLinkPart.Text = textPart.Text.Substring(lastindex, linkMatch.Index - lastindex);
// and try other smartlinks on this part
var parts = ParseSmartLinks(notLinkPart, subLinks);
foreach (var part in parts) {
- msg.Add(part);
+ msgParts.Add(part);
}
}
@@ -923,7 +922,7 @@ namespace Smuxi.Engine
model = new TextMessagePartModel(text);
break;
}
- msg.Add(model);
+ msgParts.Add(model);
lastindex = linkMatch.Index + linkMatch.Length;
linkMatch = linkMatch.NextMatch();
} while (linkMatch.Success);
@@ -937,10 +936,10 @@ namespace Smuxi.Engine
// and try other smartlinks on this part
var parts = ParseSmartLinks(notLinkPart, subLinks);
foreach (var part in parts) {
- msg.Add(part);
+ msgParts.Add(part);
}
}
- return msg;
+ return msgParts;
}
public IEnumerable<MessagePartModel> ParseSmartLinks(TextMessagePartModel part)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]