Skip to content

Commit 9648f54

Browse files
committed
Dealt with missing methods for types, dates, and strings.
1 parent 2a1a7a3 commit 9648f54

File tree

14 files changed

+161
-15
lines changed

14 files changed

+161
-15
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Globalization;
3+
4+
namespace TestStack.BDDfy
5+
{
6+
public static class DateTimeExtensions
7+
{
8+
public static string AsShortDateTimeString(this DateTime dateTime)
9+
{
10+
return dateTime.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern);
11+
}
12+
}
13+
}

src/TestStack.BDDfy/Processors/ExceptionProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private static IEnumerable<Type> GetTypesSafely(Assembly assembly)
5656
//http://stackoverflow.com/questions/520290/how-can-i-get-the-default-value-of-a-type-in-a-non-generic-way
5757
static object DefaultValue(Type myType)
5858
{
59-
return !myType.IsValueType ? null : Activator.CreateInstance(myType);
59+
return !myType.IsValueType() ? null : Activator.CreateInstance(myType);
6060
}
6161

6262
public ExceptionProcessor() : this(BestGuessInconclusiveAssertion)

src/TestStack.BDDfy/Reporters/Html/ClassicReportBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private void HtmlHead()
4646
EmbedCssFile(HtmlReportResources.classic_css_min);
4747
EmbedCssFile(_model.CustomStylesheet, HtmlReportResources.CustomStylesheetComment);
4848

49-
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _model.RunDate.ToString(CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern)));
49+
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _model.RunDate.AsShortDateTimeString()));
5050
}
5151
}
5252

src/TestStack.BDDfy/Reporters/Html/DefaultHtmlReportConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ private static string AssemblyDirectory
5151
{
5252
get
5353
{
54-
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
54+
var codeBase = typeof(DefaultHtmlReportConfiguration).Assembly().CodeBase;
5555
var uri = new UriBuilder(codeBase);
56-
string path = Uri.UnescapeDataString(uri.Path);
56+
var path = Uri.UnescapeDataString(uri.Path);
5757
return Path.GetDirectoryName(path);
5858
}
5959
}

src/TestStack.BDDfy/Reporters/Html/HtmlReportResources.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/TestStack.BDDfy/Reporters/Html/MetroReportBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private void HtmlHead()
4545
EmbedCssFile(HtmlReportResources.metro_css_min);
4646
EmbedCssFile(_model.CustomStylesheet, HtmlReportResources.CustomStylesheetComment);
4747
AddLine("<link href='http://fonts.googleapis.com/css?family=Roboto:400,300' rel='stylesheet' type='text/css'>");
48-
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _model.RunDate.ToShortDateString()));
48+
AddLine(string.Format("<title>BDDfy Test Result {0}</title>", _model.RunDate.AsShortDateTimeString()));
4949
}
5050
}
5151

src/TestStack.BDDfy/Reporters/Writers/FileWriter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private static string GetDefaultOutputDirectory
2020
{
2121
get
2222
{
23-
string codeBase = typeof(DiagnosticsReporter).Assembly.CodeBase;
23+
string codeBase = typeof(DiagnosticsReporter).Assembly().CodeBase;
2424
var uri = new UriBuilder(codeBase);
2525
string path = Uri.UnescapeDataString(uri.Path);
2626
return Path.GetDirectoryName(path);

src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleTable.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public static bool HeaderMatches(string header, string name)
9191
if (name == null)
9292
return false;
9393

94-
return Sanitise(name).Equals(Sanitise(header), StringComparison.InvariantCultureIgnoreCase);
94+
return Sanitise(name).ToLower().Equals(Sanitise(header).ToLower());
9595
}
9696

9797
private static string Sanitise(string value)

src/TestStack.BDDfy/Scanners/StepScanners/Examples/ExampleValue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public object GetValue(Type targetType)
3434
var stringValue = _underlyingValue as string;
3535
if (_underlyingValue == null)
3636
{
37-
if (targetType.IsValueType && !(targetType.IsGenericType && targetType.GetGenericTypeDefinition() == typeof(Nullable<>)))
37+
if (targetType.IsValueType() && !(targetType.IsGenericType() && targetType.GetGenericTypeDefinition() == typeof(Nullable<>)))
3838
{
3939
var valueAsString = string.IsNullOrEmpty(stringValue) ? "<null>" : string.Format("\"{0}\"", _underlyingValue);
4040
throw new ArgumentException(string.Format("Cannot convert {0} to {1} (Column: '{2}', Row: {3})", valueAsString, targetType.Name, Header, Row));
@@ -48,7 +48,7 @@ public object GetValue(Type targetType)
4848
if (targetType.IsInstanceOfType(_underlyingValue))
4949
return _underlyingValue;
5050

51-
if (targetType.IsEnum && _underlyingValue is string)
51+
if (targetType.IsEnum() && _underlyingValue is string)
5252
return Enum.Parse(targetType, (string)_underlyingValue);
5353

5454
if (targetType == typeof(DateTime))

src/TestStack.BDDfy/Scanners/StepScanners/Fluent/FluentScanner.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void AddStep(Action stepAction, string title, bool reports, ExecutionOrde
6464

6565
private string AppendPrefix(string title, string stepPrefix)
6666
{
67-
if (!title.StartsWith(stepPrefix, StringComparison.InvariantCultureIgnoreCase))
67+
if (!title.ToLower().StartsWith(stepPrefix.ToLower()))
6868
{
6969
if (title.Length == 0)
7070
return string.Format("{0} ", stepPrefix);

0 commit comments

Comments
 (0)