Template
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System.Diagnostics.CodeAnalysis;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Strata.DecisionSupport.Biz.Test.Integration
|
|
{
|
|
[ExcludeFromCodeCoverage]
|
|
public static class TestExtensions
|
|
{
|
|
/// <summary>
|
|
/// The test name
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <returns>
|
|
/// The name of the test split by camel case for a max length of 200 characters.
|
|
/// </returns>
|
|
public static string TestName(this TestContext context, string suffix = "")
|
|
{
|
|
var testName = suffix == string.Empty
|
|
? $"{context.Test.Name}".SplitCamelCase()
|
|
: $"{context.Test.Name} - {suffix}".SplitCamelCase();
|
|
testName = testName[..Math.Min(200, testName.Length)];
|
|
return testName;
|
|
}
|
|
|
|
public static string SplitCamelCase(this string input)
|
|
{
|
|
if (string.IsNullOrEmpty(input)) { return input; }
|
|
|
|
const string pattern = "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-r + t-z])|[A-Z](?=[A-Z][s][a-z]))";
|
|
|
|
if (input.StartsWith("FY", StringComparison.Ordinal))
|
|
{ // hack for FY2012, etc
|
|
return "FY " + Regex.Replace(input.Remove(0, 2), pattern, "$1 ");
|
|
}
|
|
input = Regex.Replace(input, @"\{|\}|:|,|\)|\(", "", RegexOptions.Singleline | RegexOptions.IgnoreCase);
|
|
return Regex.Replace(input, pattern, "$1 ");
|
|
}
|
|
|
|
public static VerifySettings TestSettings()
|
|
{
|
|
var settings = new VerifySettings();
|
|
settings.UseDirectory("snapshots");
|
|
settings.ScrubInlineGuids();
|
|
return settings;
|
|
}
|
|
|
|
}
|
|
}
|