string formatting because lolwindows

This commit is contained in:
Brendan Forster
2014-03-08 17:30:30 +11:00
committed by Tim Sneed
parent abfb59fb49
commit 76f4cd23e3
5 changed files with 30 additions and 3 deletions
@@ -19,7 +19,10 @@ namespace Octokit.Tests.Conventions
static string CreateMessage(Type type, IEnumerable<string> methods)
{
var methodsFormatted = String.Join("\r\n", methods.Select(m => String.Format(" - {0}", m)));
return String.Format("Methods found on type {0} which should be removed:\r\n{1}", type.Name, methodsFormatted);
return "Methods found on type {0} which should be removed:\r\n{1}"
.FormatWithNewLine(
type.Name,
methodsFormatted);
}
}
}
@@ -36,7 +36,13 @@ namespace Octokit.Tests.Conventions
var formattedMainMethods = String.Join("\r\n", mainMethods.Select(Format).Select(m => String.Format(" - {0}", m)));
var formattedObservableMethods = String.Join("\r\n", observableMethods.Select(Format).Select(m => String.Format(" - {0}", m)));
return String.Format("There are some overloads which are confusing the convention tests. Check everything is okay in these types:\r\n{0}\r\n{2}\r\n{1}\r\n{3}", clientInterface.Name, observableInterface.Name, formattedMainMethods, formattedObservableMethods);
return
"There are some overloads which are confusing the convention tests. Check everything is okay in these types:\r\n{0}\r\n{1}\r\n{2}\r\n{3}"
.FormatWithNewLine(
clientInterface.Name,
formattedMainMethods,
observableInterface.Name,
formattedObservableMethods);
}
}
}
@@ -19,7 +19,8 @@ namespace Octokit.Tests.Conventions
static string CreateMessage(Type type, IEnumerable<string> methods)
{
var methodsFormatted = String.Join("\r\n", methods.Select(m => String.Format(" - {0}", m)));
return String.Format("Methods not found on interface {0} which are required:\r\n{1}", type.Name, methodsFormatted);
return "Methods not found on interface {0} which are required:\r\n{1}"
.FormatWithNewLine(type.Name, methodsFormatted);
}
}
}
@@ -58,6 +58,7 @@
<Compile Include="Exception\ParameterMismatchException.cs" />
<Compile Include="Exception\ReturnValueMismatchException.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="StringExtensions.cs" />
<Compile Include="SyncObservableClients.cs" />
<Compile Include="TypeExtensions.cs" />
</ItemGroup>
@@ -0,0 +1,16 @@
using System;
namespace Octokit.Tests.Conventions
{
internal static class StringExtensions
{
public static string FormatWithNewLine(this string s, params object[] args)
{
var template = Environment.NewLine == "\r\n"
? s
: s.Replace("\r\n", Environment.NewLine);
return String.Format(template, args);
}
}
}