|
| 1 | +using NUnit.Framework; |
| 2 | + |
| 3 | +namespace TestStack.BDDfy.Tests.Stories |
| 4 | +{ |
| 5 | + class InOrderToStoryAttribute : StoryNarrativeAttribute |
| 6 | + { |
| 7 | + // ReSharper disable InconsistentNaming |
| 8 | + private const string As_a_prefix = "As a"; |
| 9 | + private const string In_order_to_prefix = "In order to"; |
| 10 | + private const string I_want_prefix = "I want"; |
| 11 | + // ReSharper restore InconsistentNaming |
| 12 | + |
| 13 | + public string InOrderTo |
| 14 | + { |
| 15 | + get { return Narrative1; } |
| 16 | + set { Narrative1 = CleanseProperty(value, In_order_to_prefix); } |
| 17 | + } |
| 18 | + |
| 19 | + public string AsA |
| 20 | + { |
| 21 | + get { return Narrative2; } |
| 22 | + set { Narrative2 = CleanseProperty(value, As_a_prefix); } |
| 23 | + } |
| 24 | + |
| 25 | + public string IWant |
| 26 | + { |
| 27 | + get { return Narrative3; } |
| 28 | + set { Narrative3 = CleanseProperty(value, I_want_prefix); } |
| 29 | + } |
| 30 | + } |
| 31 | + |
| 32 | + [TestFixture] |
| 33 | + [InOrderToStory( |
| 34 | + InOrderTo = "do something", |
| 35 | + AsA = "programmer", |
| 36 | + IWant = "this to work")] |
| 37 | + public class CanUseACustomStoryAttribute |
| 38 | + { |
| 39 | + [Test] |
| 40 | + public void When_InOrderTo_is_specified_the_InOrderTo_syntax_is_used() |
| 41 | + { |
| 42 | + var story = new DummyScenario().BDDfy<CanUseACustomStoryAttribute>(); |
| 43 | + |
| 44 | + Assert.That(story.Metadata.Narrative1, Is.EqualTo("In order to do something")); |
| 45 | + Assert.That(story.Metadata.Narrative2, Is.EqualTo("As a programmer")); |
| 46 | + Assert.That(story.Metadata.Narrative3, Is.EqualTo("I want this to work")); |
| 47 | + } |
| 48 | + } |
| 49 | +} |
0 commit comments