Modified:
/trunk/TinyBDD/Dsl/GivenWhenThen/Semantics.cs
/trunk/TinyBDD/Dsl/GivenWhenThen/TestMetadataParser.cs
/trunk/TinyBDDTests/Dsl/GivenWhenThen/SemanticsTests.cs
=======================================
--- /trunk/TinyBDD/Dsl/GivenWhenThen/Semantics.cs Sat May 30 05:38:42 2009
+++ /trunk/TinyBDD/Dsl/GivenWhenThen/Semantics.cs Tue Nov 3 15:22:32 2009
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using System.Reflection;
+using System.Diagnostics;
namespace TinyBDD.Dsl.GivenWhenThen
{
@@ -61,9 +62,20 @@
public ThenSemantics Then(Then then)
{
- return Then(metadataParser.TranslateToText(then),
+ var text = metadataParser.TranslateToText(then);
+ if (text == string.Empty)
+ text = GetCallersMethodName();
+
+ return Then(text,
() => { then(); });
}
+
+ private string GetCallersMethodName()
+ {
+ var st = new StackTrace();
+ var name = st.GetFrames().Skip(2).First().GetMethod().Name;
+ return metadataParser.FormatText(name);
+ }
public ThenSemantics Then(string text)
{
=======================================
--- /trunk/TinyBDD/Dsl/GivenWhenThen/TestMetadataParser.cs Thu Aug 20
00:35:16 2009
+++ /trunk/TinyBDD/Dsl/GivenWhenThen/TestMetadataParser.cs Tue Nov 3
15:22:32 2009
@@ -70,7 +70,7 @@
return string.Empty;
}
- private string FormatText(string title)
+ public string FormatText(string title)
{
title = title.Replace("_", " ");
return title;
=======================================
--- /trunk/TinyBDDTests/Dsl/GivenWhenThen/SemanticsTests.cs Thu Aug 20
00:35:16 2009
+++ /trunk/TinyBDDTests/Dsl/GivenWhenThen/SemanticsTests.cs Tue Nov 3
15:22:32 2009
@@ -129,6 +129,15 @@
semanticModelState.Acts.Values.First().First().Text.ShouldBe("user should
be deleted from the database");
}
+
+ [Test]
+ public void
Then_should_add_assert_to_the_semanticModel_when_code_block_is_specified()
+ {
+ semantics.When(user_is_deleted);
+ semantics.Then(() => { });
+
+
semanticModelState.Acts.Values.First().First().Text.ShouldBe("Then should
add assert to the semanticModel when code block is specified");
+ }
[Test]
public void
Reused_context_should_be_translated_to_a_title_if_its_a_private_field_in_test_class()