From 7c3dcc6a082b1da04eea0c88502a79734b2beb88 Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Mon, 27 Jan 2014 02:48:59 +0100 Subject: [PATCH 1/3] #25 red: added ObjectDisposalFeature.RegisteringManyDisposableObjectsInAnAsyncStep --- .../ObjectDisposalFeature.cs | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs b/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs index 8baf306b..f459cd73 100644 --- a/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs +++ b/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs @@ -9,6 +9,7 @@ namespace Xbehave.Test.Acceptance using System.Collections.Concurrent; using System.Collections.Generic; using System.Linq; + using System.Threading.Tasks; using FluentAssertions; using Xbehave.Test.Acceptance.Infrastructure; using Xunit.Sdk; @@ -213,6 +214,31 @@ public static void FailureToCompleteAStep() .And(() => DisposableObjectsShouldEachHaveBeenDisposedOnceInReverseOrder()); } +#if NET45 + [Scenario] + public static void RegisteringManyDisposableObjectsInAnAsyncStep() + { + var feature = default(Type); + var results = default(MethodResult[]); + + "Given a step which registers many disposable objects in an async step" + .Given(() => feature = typeof(AsyncStep)); + + "When running the scenario" + .When(() => results = TestRunner.Run(feature).ToArray()) + .Teardown(Disposable.ClearRecordedEvents); + + "Then there should be no failures" + .Then(() => results.Should().NotContain(result => result is FailedResult)); + + "And some disposable objects should have been created" + .And(() => SomeDisposableObjectsShouldHaveBeenCreated()); + + "And the disposable objects should each have been disposed once in reverse order" + .And(() => DisposableObjectsShouldEachHaveBeenDisposedOnceInReverseOrder()); + } +#endif + private static AndConstraint> SomeDisposableObjectsShouldHaveBeenCreated() { return Disposable.RecordedEvents.Where(@event => @event.EventType == LifeTimeEventType.Constructed).Should().NotBeEmpty(); @@ -414,6 +440,32 @@ public static void Scenario() } } +#if NET45 + private static class AsyncStep + { + [Scenario] + public static void Scenario(Disposable disposable0, Disposable disposable1, Disposable disposable2) + { + "Given some disposables" + .Given(async () => + { + await Task.Yield(); + disposable0 = new Disposable().Using(); + disposable1 = new Disposable().Using(); + disposable2 = new Disposable().Using(); + }); + + "When using the disposables" + .When(() => + { + disposable0.Use(); + disposable1.Use(); + disposable2.Use(); + }); + } + } +#endif + private class Disposable : IDisposable { private static readonly ConcurrentQueue Events = new ConcurrentQueue(); From 51bd3da4d4dffd638d6133318f3d51a7bfe5520f Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Mon, 3 Mar 2014 17:15:27 +0100 Subject: [PATCH 2/3] #25 green: added step overloads with a step context parameter --- src/Xbehave.Net35/Xbehave.Net35.csproj | 6 ++ src/Xbehave.Net40/DisposableExtensions.cs | 16 +++ src/Xbehave.Net40/Helper.cs | 8 ++ src/Xbehave.Net40/IStepContext.cs | 23 +++++ src/Xbehave.Net40/StepContext.cs | 26 +++++ src/Xbehave.Net40/StepExtensions.cs | 80 +++++++++++++++ src/Xbehave.Net40/StringExtensions.cs | 99 +++++++++++++++++++ src/Xbehave.Net40/Xbehave.Net40.csproj | 2 + src/Xbehave.Net40/_.cs | 90 +++++++++++++++++ src/Xbehave.Net45/Helper.Async.cs | 8 ++ src/Xbehave.Net45/StringExtensions.Async.cs | 99 +++++++++++++++++++ src/Xbehave.Net45/Xbehave.Net45.csproj | 6 ++ src/Xbehave.Sdk.Net40/Step.cs | 19 ++++ src/Xbehave.Sdk.Net40/SyncStep.cs | 8 +- src/Xbehave.Sdk.Net45/AsyncStep.cs | 5 + .../ObjectDisposalFeature.cs | 54 +++++----- .../Xbehave.Features.Net40/TeardownFeature.cs | 16 +-- 17 files changed, 528 insertions(+), 37 deletions(-) create mode 100644 src/Xbehave.Net40/IStepContext.cs create mode 100644 src/Xbehave.Net40/StepContext.cs diff --git a/src/Xbehave.Net35/Xbehave.Net35.csproj b/src/Xbehave.Net35/Xbehave.Net35.csproj index 295fa474..45df4d70 100644 --- a/src/Xbehave.Net35/Xbehave.Net35.csproj +++ b/src/Xbehave.Net35/Xbehave.Net35.csproj @@ -66,9 +66,15 @@ ContinueOnFailureAfterAttribute.cs + + IStepContext.cs + OmitArgumentsFromScenarioNamesAttribute.cs + + StepContext.cs + StepType.cs diff --git a/src/Xbehave.Net40/DisposableExtensions.cs b/src/Xbehave.Net40/DisposableExtensions.cs index 1dff8dea..dba330dd 100644 --- a/src/Xbehave.Net40/DisposableExtensions.cs +++ b/src/Xbehave.Net40/DisposableExtensions.cs @@ -18,6 +18,7 @@ public static class DisposableExtensions /// The type of the object. /// The object to be disposed. /// The object. + [Obsolete("Use Using(IStep) instead. This deprecated version of the method will fail to register objects for disposal in async steps, in steps with timeouts, or when called from a thread other than the scenario execution thread.")] public static T Using(this T obj) where T : IDisposable { if (obj != null) @@ -27,5 +28,20 @@ public static class DisposableExtensions return obj; } + + /// + /// Immediately registers the object for disposal after all steps in the current scenario have been executed. + /// + /// The type of the object. + /// The object to be disposed. + /// The execution context for the current step. + /// The object. + public static T Using(this T obj, IStepContext stepContext) where T : IDisposable + { + Guard.AgainstNullArgument("stepContext", stepContext); + + stepContext.Using(obj); + return obj; + } } } diff --git a/src/Xbehave.Net40/Helper.cs b/src/Xbehave.Net40/Helper.cs index 275e99fd..503a275f 100644 --- a/src/Xbehave.Net40/Helper.cs +++ b/src/Xbehave.Net40/Helper.cs @@ -13,5 +13,13 @@ public static Fluent.IStep AddStep(string text, Action body, StepType stepType) { return new Fluent.Step(CurrentScenario.AddStep(text, body, stepType)); } + + public static Fluent.IStep AddStep(string text, Action body, StepType stepType) + { + var context = new StepContext(); + var step = CurrentScenario.AddStep(text, () => body(context), stepType); + context.Assign(step); + return new Fluent.Step(step); + } } } diff --git a/src/Xbehave.Net40/IStepContext.cs b/src/Xbehave.Net40/IStepContext.cs new file mode 100644 index 00000000..84da403f --- /dev/null +++ b/src/Xbehave.Net40/IStepContext.cs @@ -0,0 +1,23 @@ +// +// Copyright (c) xBehave.net contributors. All rights reserved. +// + +namespace Xbehave +{ + using System; + using System.Diagnostics.CodeAnalysis; + + /// + /// A scenario step context. + /// + public interface IStepContext + { + /// + /// Immediately registers the object for disposal after all steps in the current scenario have been executed. + /// + /// The object to be disposed. + /// The current . + [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Using", Justification = "Makes sense here.")] + IStepContext Using(IDisposable disposable); + } +} \ No newline at end of file diff --git a/src/Xbehave.Net40/StepContext.cs b/src/Xbehave.Net40/StepContext.cs new file mode 100644 index 00000000..7780e48c --- /dev/null +++ b/src/Xbehave.Net40/StepContext.cs @@ -0,0 +1,26 @@ +// +// Copyright (c) xBehave.net contributors. All rights reserved. +// + +namespace Xbehave +{ + using System; + + internal partial class StepContext : IStepContext + { + private Sdk.Step step; + + public void Assign(Sdk.Step step) + { + Guard.AgainstNullArgument("step", step); + + this.step = step; + } + + public IStepContext Using(IDisposable disposable) + { + this.step.AddDisposable(disposable); + return this; + } + } +} diff --git a/src/Xbehave.Net40/StepExtensions.cs b/src/Xbehave.Net40/StepExtensions.cs index 57b92ad2..0b71f2cb 100644 --- a/src/Xbehave.Net40/StepExtensions.cs +++ b/src/Xbehave.Net40/StepExtensions.cs @@ -95,5 +95,85 @@ public static IStep But(this IStep stepDefinition, string text, Action body) { return Helper.AddStep("But " + text, body, StepType.But); } + + /// + /// Defines a step in the current scenario. + /// + /// The step definition. + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "stepDefinition", Justification = "Part of fluent API.")] + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep When(this IStep stepDefinition, string text, Action body) + { + return Helper.AddStep("When " + text, body, StepType.When); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step definition. + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "stepDefinition", Justification = "Part of fluent API.")] + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep Then(this IStep stepDefinition, string text, Action body) + { + return Helper.AddStep("Then " + text, body, StepType.Then); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step definition. + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "stepDefinition", Justification = "Part of fluent API.")] + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep And(this IStep stepDefinition, string text, Action body) + { + return Helper.AddStep("And " + text, body, StepType.And); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step definition. + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "stepDefinition", Justification = "Part of fluent API.")] + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep But(this IStep stepDefinition, string text, Action body) + { + return Helper.AddStep("But " + text, body, StepType.But); + } } } diff --git a/src/Xbehave.Net40/StringExtensions.cs b/src/Xbehave.Net40/StringExtensions.cs index b5e91aa2..efc1312f 100644 --- a/src/Xbehave.Net40/StringExtensions.cs +++ b/src/Xbehave.Net40/StringExtensions.cs @@ -111,6 +111,105 @@ public static IStep _(this string text, Action body) return Helper.AddStep(text, body, stepType); } + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep Given(this string text, Action body) + { + return Helper.AddStep(text, body, StepType.Given); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep When(this string text, Action body) + { + return Helper.AddStep(text, body, StepType.When); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep Then(this string text, Action body) + { + return Helper.AddStep(text, body, StepType.Then); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep And(this string text, Action body) + { + return Helper.AddStep(text, body, StepType.And); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep But(this string text, Action body) + { + return Helper.AddStep(text, body, StepType.But); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "f", Justification = "Fluent API")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "f", Justification = "Fluent API")] + [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Fluent API")] + public static IStep f(this string text, Action body) + { + var stepType = GetStepType(text); + return Helper.AddStep(text, body, stepType); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "_", Justification = "Fluent API")] + [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Fluent API")] + [CLSCompliant(false)] + public static IStep _(this string text, Action body) + { + var stepType = GetStepType(text); + return Helper.AddStep(text, body, stepType); + } + /// /// Get the appropriate step type based on the the text. /// diff --git a/src/Xbehave.Net40/Xbehave.Net40.csproj b/src/Xbehave.Net40/Xbehave.Net40.csproj index 581fa186..2819fca3 100644 --- a/src/Xbehave.Net40/Xbehave.Net40.csproj +++ b/src/Xbehave.Net40/Xbehave.Net40.csproj @@ -61,12 +61,14 @@ Properties\CommonAssemblyInfo.cs + + diff --git a/src/Xbehave.Net40/_.cs b/src/Xbehave.Net40/_.cs index 5e4b06fb..a32de485 100644 --- a/src/Xbehave.Net40/_.cs +++ b/src/Xbehave.Net40/_.cs @@ -105,5 +105,95 @@ public static IStep But(string text, Action body) { return Helper.AddStep("But " + text, body, StepType.But); } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep Given(string text, Action body) + { + return Helper.AddStep("Given " + text, body, StepType.Given); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep When(string text, Action body) + { + return Helper.AddStep("When " + text, body, StepType.When); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep Then(string text, Action body) + { + return Helper.AddStep("Then " + text, body, StepType.Then); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep And(string text, Action body) + { + return Helper.AddStep("And " + text, body, StepType.And); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage( + "Microsoft.Globalization", + "CA1303:Do not pass literals as localized parameters", + MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + Justification = "Text must match method name.")] + public static IStep But(string text, Action body) + { + return Helper.AddStep("But " + text, body, StepType.But); + } } } diff --git a/src/Xbehave.Net45/Helper.Async.cs b/src/Xbehave.Net45/Helper.Async.cs index 3e52751f..8000012c 100644 --- a/src/Xbehave.Net45/Helper.Async.cs +++ b/src/Xbehave.Net45/Helper.Async.cs @@ -14,5 +14,13 @@ public static Fluent.IStep AddStep(string text, Func body, StepType stepTy { return new Fluent.Step(CurrentScenario.AddStep(text, body, stepType)); } + + public static Fluent.IStep AddStep(string text, Func body, StepType stepType) + { + var context = new StepContext(); + var step = CurrentScenario.AddStep(text, () => body(context), stepType); + context.Assign(step); + return new Fluent.Step(step); + } } } diff --git a/src/Xbehave.Net45/StringExtensions.Async.cs b/src/Xbehave.Net45/StringExtensions.Async.cs index 64f5904e..da073cc1 100644 --- a/src/Xbehave.Net45/StringExtensions.Async.cs +++ b/src/Xbehave.Net45/StringExtensions.Async.cs @@ -112,5 +112,104 @@ public static IStep _(this string text, Func body) var stepType = StringExtensions.GetStepType(text); return Helper.AddStep(text, body, stepType); } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep Given(this string text, Func body) + { + return Helper.AddStep(text, body, StepType.Given); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep When(this string text, Func body) + { + return Helper.AddStep(text, body, StepType.When); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep Then(this string text, Func body) + { + return Helper.AddStep(text, body, StepType.Then); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep And(this string text, Func body) + { + return Helper.AddStep(text, body, StepType.And); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + public static IStep But(this string text, Func body) + { + return Helper.AddStep(text, body, StepType.But); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "f", Justification = "Fluent API")] + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "f", Justification = "Fluent API")] + [SuppressMessage("Microsoft.StyleCop.CSharp.NamingRules", "SA1300:ElementMustBeginWithUpperCaseLetter", Justification = "Fluent API")] + public static IStep f(this string text, Func body) + { + var stepType = StringExtensions.GetStepType(text); + return Helper.AddStep(text, body, stepType); + } + + /// + /// Defines a step in the current scenario. + /// + /// The step text. + /// The action that will perform the step. + /// + /// An instance of . + /// + [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "_", Justification = "Fluent API")] + [SuppressMessage("Microsoft.Naming", "CA1707:IdentifiersShouldNotContainUnderscores", Justification = "Fluent API")] + [CLSCompliant(false)] + public static IStep _(this string text, Func body) + { + var stepType = StringExtensions.GetStepType(text); + return Helper.AddStep(text, body, stepType); + } } } diff --git a/src/Xbehave.Net45/Xbehave.Net45.csproj b/src/Xbehave.Net45/Xbehave.Net45.csproj index 40a3defc..04800fee 100644 --- a/src/Xbehave.Net45/Xbehave.Net45.csproj +++ b/src/Xbehave.Net45/Xbehave.Net45.csproj @@ -79,6 +79,9 @@ Helper.cs + + IStepContext.cs + OmitArgumentsFromScenarioNamesAttribute.cs @@ -94,6 +97,9 @@ ScenarioAttribute.cs + + StepContext.cs + StepExtensions.cs diff --git a/src/Xbehave.Sdk.Net40/Step.cs b/src/Xbehave.Sdk.Net40/Step.cs index 655d10f1..93ab7581 100644 --- a/src/Xbehave.Sdk.Net40/Step.cs +++ b/src/Xbehave.Sdk.Net40/Step.cs @@ -17,6 +17,7 @@ public abstract partial class Step { private readonly string name; private readonly object stepType; + private readonly List disposables = new List(); private readonly List teardowns = new List(); public Step(string name, object stepType) @@ -36,6 +37,16 @@ public object StepType get { return this.stepType; } } + public IEnumerable ExtractDisposables + { + get + { + var extracted = this.disposables.ToArray(); + this.disposables.Clear(); + return extracted; + } + } + public IEnumerable Teardowns { get { return this.teardowns.Select(x => x); } @@ -47,6 +58,14 @@ public IEnumerable Teardowns public int MillisecondsTimeout { get; set; } + public void AddDisposable(IDisposable disposable) + { + if (disposable != null) + { + this.disposables.Add(disposable); + } + } + public void AddTeardown(Action teardown) { if (teardown != null) diff --git a/src/Xbehave.Sdk.Net40/SyncStep.cs b/src/Xbehave.Sdk.Net40/SyncStep.cs index 584b53c5..17715752 100644 --- a/src/Xbehave.Sdk.Net40/SyncStep.cs +++ b/src/Xbehave.Sdk.Net40/SyncStep.cs @@ -50,7 +50,6 @@ public override void Execute() } finally { - teardowns = CurrentScenario.ExtractTeardowns(); SynchronizationContext.SetSynchronizationContext(oldSyncContext); @event.Set(); } @@ -70,7 +69,12 @@ public override void Execute() } finally { - foreach (var teardown in teardowns.Concat(this.Teardowns)) + foreach (var disposable in this.ExtractDisposables) + { + CurrentScenario.AddTeardown(() => disposable.Dispose()); + } + + foreach (var teardown in this.Teardowns) { CurrentScenario.AddTeardown(teardown); } diff --git a/src/Xbehave.Sdk.Net45/AsyncStep.cs b/src/Xbehave.Sdk.Net45/AsyncStep.cs index 2689d645..4227ea5c 100644 --- a/src/Xbehave.Sdk.Net45/AsyncStep.cs +++ b/src/Xbehave.Sdk.Net45/AsyncStep.cs @@ -35,6 +35,11 @@ public override void Execute() } finally { + foreach (var disposable in this.ExtractDisposables) + { + CurrentScenario.AddTeardown(() => disposable.Dispose()); + } + foreach (var teardown in this.Teardowns) { CurrentScenario.AddTeardown(teardown); diff --git a/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs b/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs index f459cd73..4b9a2114 100644 --- a/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs +++ b/src/test/Xbehave.Features.Net40/ObjectDisposalFeature.cs @@ -272,11 +272,11 @@ public static void Scenario() var disposable2 = default(Disposable); "Given some disposables" - .Given(() => + .Given(c => { - disposable0 = new Disposable().Using(); - disposable1 = new Disposable().Using(); - disposable2 = new Disposable().Using(); + disposable0 = new Disposable().Using(c); + disposable1 = new Disposable().Using(c); + disposable2 = new Disposable().Using(c); }); "When using the disposables" @@ -299,11 +299,11 @@ public static void Scenario() var disposable2 = default(BadDisposable); "Given some disposables" - .Given(() => + .Given(c => { - disposable0 = new BadDisposable().Using(); - disposable1 = new BadDisposable().Using(); - disposable2 = new BadDisposable().Using(); + disposable0 = new BadDisposable().Using(c); + disposable1 = new BadDisposable().Using(c); + disposable2 = new BadDisposable().Using(c); }); "When using the disposables" @@ -326,11 +326,11 @@ public static void Scenario() var disposable2 = default(SingleRecursionBadDisposable); "Given some disposables" - .Given(() => + .Given(c => { - disposable0 = new SingleRecursionBadDisposable().Using(); - disposable1 = new SingleRecursionBadDisposable().Using(); - disposable2 = new SingleRecursionBadDisposable().Using(); + disposable0 = new SingleRecursionBadDisposable().Using(c); + disposable1 = new SingleRecursionBadDisposable().Using(c); + disposable2 = new SingleRecursionBadDisposable().Using(c); }); "When using the disposables" @@ -353,13 +353,13 @@ public static void Scenario() var disposable2 = default(Disposable); "Given a disposable" - .Given(() => disposable0 = new Disposable().Using()); + .Given(c => disposable0 = new Disposable().Using(c)); "And another disposable" - .Given(() => disposable1 = new Disposable().Using()); + .Given(c => disposable1 = new Disposable().Using(c)); "And another disposable" - .Given(() => disposable2 = new Disposable().Using()); + .Given(c => disposable2 = new Disposable().Using(c)); "When using the disposables" .When(() => @@ -379,7 +379,7 @@ public static void Scenario() var disposable0 = default(Disposable); "Given a disposable" - .Given(() => disposable0 = new Disposable().Using()); + .Given(c => disposable0 = new Disposable().Using(c)); "When using the disposable" .When(() => disposable0.Use()); @@ -403,13 +403,13 @@ public static void Scenario() var disposable2 = default(Disposable); "Given a disposable" - .Given(() => disposable0 = new Disposable().Using()); + .Given(c => disposable0 = new Disposable().Using(c)); "And another disposable" - .Given(() => disposable1 = new Disposable().Using()); + .Given(c => disposable1 = new Disposable().Using(c)); "And another disposable" - .Given(() => disposable2 = new Disposable().Using()); + .Given(c => disposable2 = new Disposable().Using(c)); "When using the disposables" .When(() => @@ -430,11 +430,11 @@ private static class StepFailsToComplete public static void Scenario() { "Given some disposables" - .Given(() => + .Given(c => { - new Disposable().Using(); - new Disposable().Using(); - new Disposable().Using(); + new Disposable().Using(c); + new Disposable().Using(c); + new Disposable().Using(c); throw new InvalidOperationException(); }); } @@ -447,12 +447,12 @@ private static class AsyncStep public static void Scenario(Disposable disposable0, Disposable disposable1, Disposable disposable2) { "Given some disposables" - .Given(async () => + .Given(async c => { await Task.Yield(); - disposable0 = new Disposable().Using(); - disposable1 = new Disposable().Using(); - disposable2 = new Disposable().Using(); + disposable0 = new Disposable().Using(c); + disposable1 = new Disposable().Using(c); + disposable2 = new Disposable().Using(c); }); "When using the disposables" diff --git a/src/test/Xbehave.Features.Net40/TeardownFeature.cs b/src/test/Xbehave.Features.Net40/TeardownFeature.cs index 67742f8a..a9da43a5 100644 --- a/src/test/Xbehave.Features.Net40/TeardownFeature.cs +++ b/src/test/Xbehave.Features.Net40/TeardownFeature.cs @@ -337,11 +337,11 @@ private static class TeardownsAndDisposables public static void Scenario() { "Given something" - .Given(() => + .Given(c => { - new Disposable(1).Using(); - new Disposable(2).Using(); - new Disposable(3).Using(); + new Disposable(1).Using(c); + new Disposable(2).Using(c); + new Disposable(3).Using(c); }) .Teardown(() => ActionIds.Enqueue(4)) .And() @@ -350,11 +350,11 @@ public static void Scenario() .Teardown(() => ActionIds.Enqueue(6)); "And something else" - .And(() => + .And(c => { - new Disposable(7).Using(); - new Disposable(8).Using(); - new Disposable(9).Using(); + new Disposable(7).Using(c); + new Disposable(8).Using(c); + new Disposable(9).Using(c); }) .Teardown(() => ActionIds.Enqueue(10)) .And() From eaa3d938d95adf5ffa70107e7696bec2920382b3 Mon Sep 17 00:00:00 2001 From: Adam Ralph Date: Mon, 3 Mar 2014 21:09:26 +0100 Subject: [PATCH 3/3] #25 refactor: merged Helper into Fluent.Step --- src/Xbehave.Net35/Xbehave.Net35.csproj | 3 -- src/Xbehave.Net40/Fluent/Step.cs | 29 +++++++++++++-- src/Xbehave.Net40/Helper.cs | 25 ------------- src/Xbehave.Net40/StepExtensions.cs | 35 +++++++++--------- src/Xbehave.Net40/StringExtensions.cs | 28 +++++++-------- src/Xbehave.Net40/Xbehave.Net40.csproj | 1 - src/Xbehave.Net40/_.cs | 40 ++++++++++----------- src/Xbehave.Net45/Helper.Async.cs | 26 -------------- src/Xbehave.Net45/StringExtensions.Async.cs | 28 +++++++-------- src/Xbehave.Net45/Xbehave.Net45.csproj | 4 --- 10 files changed, 91 insertions(+), 128 deletions(-) delete mode 100644 src/Xbehave.Net40/Helper.cs delete mode 100644 src/Xbehave.Net45/Helper.Async.cs diff --git a/src/Xbehave.Net35/Xbehave.Net35.csproj b/src/Xbehave.Net35/Xbehave.Net35.csproj index 45df4d70..574b1b38 100644 --- a/src/Xbehave.Net35/Xbehave.Net35.csproj +++ b/src/Xbehave.Net35/Xbehave.Net35.csproj @@ -97,9 +97,6 @@ Fluent\Step.cs - - Helper.cs - Properties\AssemblyInfo.cs diff --git a/src/Xbehave.Net40/Fluent/Step.cs b/src/Xbehave.Net40/Fluent/Step.cs index 0734dd8b..56816be7 100644 --- a/src/Xbehave.Net40/Fluent/Step.cs +++ b/src/Xbehave.Net40/Fluent/Step.cs @@ -5,16 +5,41 @@ namespace Xbehave.Fluent { using System; +#if NET45 + using System.Threading.Tasks; +#endif + using Xbehave.Sdk; internal partial class Step : IStep { private readonly Sdk.Step step; - public Step(Sdk.Step step) + public Step(string text, Action body, StepType stepType) { - this.step = step; + this.step = CurrentScenario.AddStep(text, body, stepType); } + public Step(string text, Action body, StepType stepType) + { + var context = new StepContext(); + this.step = CurrentScenario.AddStep(text, () => body(context), stepType); + context.Assign(this.step); + } + +#if NET45 + public Step(string text, Func body, StepType stepType) + { + this.step = CurrentScenario.AddStep(text, body, stepType); + } + + public Step(string text, Func body, StepType stepType) + { + var context = new StepContext(); + this.step = CurrentScenario.AddStep(text, () => body(context), stepType); + context.Assign(this.step); + } + +#endif public IStep And() { return this; diff --git a/src/Xbehave.Net40/Helper.cs b/src/Xbehave.Net40/Helper.cs deleted file mode 100644 index 503a275f..00000000 --- a/src/Xbehave.Net40/Helper.cs +++ /dev/null @@ -1,25 +0,0 @@ -// -// Copyright (c) xBehave.net contributors. All rights reserved. -// - -namespace Xbehave -{ - using System; - using Xbehave.Sdk; - - internal static partial class Helper - { - public static Fluent.IStep AddStep(string text, Action body, StepType stepType) - { - return new Fluent.Step(CurrentScenario.AddStep(text, body, stepType)); - } - - public static Fluent.IStep AddStep(string text, Action body, StepType stepType) - { - var context = new StepContext(); - var step = CurrentScenario.AddStep(text, () => body(context), stepType); - context.Assign(step); - return new Fluent.Step(step); - } - } -} diff --git a/src/Xbehave.Net40/StepExtensions.cs b/src/Xbehave.Net40/StepExtensions.cs index 0b71f2cb..a477ac3b 100644 --- a/src/Xbehave.Net40/StepExtensions.cs +++ b/src/Xbehave.Net40/StepExtensions.cs @@ -6,9 +6,6 @@ namespace Xbehave { using System; using System.Diagnostics.CodeAnalysis; - - using Sdk; - using Xbehave.Fluent; /// @@ -29,11 +26,11 @@ public static partial class StepExtensions [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep When(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("When " + text, body, StepType.When); + return new Step("When " + text, body, StepType.When); } /// @@ -49,11 +46,11 @@ public static IStep When(this IStep stepDefinition, string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep Then(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("Then " + text, body, StepType.Then); + return new Step("Then " + text, body, StepType.Then); } /// @@ -69,11 +66,11 @@ public static IStep Then(this IStep stepDefinition, string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep And(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("And " + text, body, StepType.And); + return new Step("And " + text, body, StepType.And); } /// @@ -89,11 +86,11 @@ public static IStep And(this IStep stepDefinition, string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep But(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("But " + text, body, StepType.But); + return new Step("But " + text, body, StepType.But); } /// @@ -109,11 +106,11 @@ public static IStep But(this IStep stepDefinition, string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep When(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("When " + text, body, StepType.When); + return new Step("When " + text, body, StepType.When); } /// @@ -129,11 +126,11 @@ public static IStep When(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("Then " + text, body, StepType.Then); + return new Step("Then " + text, body, StepType.Then); } /// @@ -149,11 +146,11 @@ public static IStep Then(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("And " + text, body, StepType.And); + return new Step("And " + text, body, StepType.And); } /// @@ -169,11 +166,11 @@ public static IStep And(this IStep stepDefinition, string text, Action body) { - return Helper.AddStep("But " + text, body, StepType.But); + return new Step("But " + text, body, StepType.But); } } } diff --git a/src/Xbehave.Net40/StringExtensions.cs b/src/Xbehave.Net40/StringExtensions.cs index efc1312f..97ccdf02 100644 --- a/src/Xbehave.Net40/StringExtensions.cs +++ b/src/Xbehave.Net40/StringExtensions.cs @@ -22,7 +22,7 @@ public static partial class StringExtensions /// public static IStep Given(this string text, Action body) { - return Helper.AddStep(text, body, StepType.Given); + return new Step(text, body, StepType.Given); } /// @@ -35,7 +35,7 @@ public static IStep Given(this string text, Action body) /// public static IStep When(this string text, Action body) { - return Helper.AddStep(text, body, StepType.When); + return new Step(text, body, StepType.When); } /// @@ -48,7 +48,7 @@ public static IStep When(this string text, Action body) /// public static IStep Then(this string text, Action body) { - return Helper.AddStep(text, body, StepType.Then); + return new Step(text, body, StepType.Then); } /// @@ -61,7 +61,7 @@ public static IStep Then(this string text, Action body) /// public static IStep And(this string text, Action body) { - return Helper.AddStep(text, body, StepType.And); + return new Step(text, body, StepType.And); } /// @@ -74,7 +74,7 @@ public static IStep And(this string text, Action body) /// public static IStep But(this string text, Action body) { - return Helper.AddStep(text, body, StepType.But); + return new Step(text, body, StepType.But); } /// @@ -91,7 +91,7 @@ public static IStep But(this string text, Action body) public static IStep f(this string text, Action body) { var stepType = GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// @@ -108,7 +108,7 @@ public static IStep f(this string text, Action body) public static IStep _(this string text, Action body) { var stepType = GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// @@ -121,7 +121,7 @@ public static IStep _(this string text, Action body) /// public static IStep Given(this string text, Action body) { - return Helper.AddStep(text, body, StepType.Given); + return new Step(text, body, StepType.Given); } /// @@ -134,7 +134,7 @@ public static IStep Given(this string text, Action body) /// public static IStep When(this string text, Action body) { - return Helper.AddStep(text, body, StepType.When); + return new Step(text, body, StepType.When); } /// @@ -147,7 +147,7 @@ public static IStep When(this string text, Action body) /// public static IStep Then(this string text, Action body) { - return Helper.AddStep(text, body, StepType.Then); + return new Step(text, body, StepType.Then); } /// @@ -160,7 +160,7 @@ public static IStep Then(this string text, Action body) /// public static IStep And(this string text, Action body) { - return Helper.AddStep(text, body, StepType.And); + return new Step(text, body, StepType.And); } /// @@ -173,7 +173,7 @@ public static IStep And(this string text, Action body) /// public static IStep But(this string text, Action body) { - return Helper.AddStep(text, body, StepType.But); + return new Step(text, body, StepType.But); } /// @@ -190,7 +190,7 @@ public static IStep But(this string text, Action body) public static IStep f(this string text, Action body) { var stepType = GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// @@ -207,7 +207,7 @@ public static IStep f(this string text, Action body) public static IStep _(this string text, Action body) { var stepType = GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// diff --git a/src/Xbehave.Net40/Xbehave.Net40.csproj b/src/Xbehave.Net40/Xbehave.Net40.csproj index 2819fca3..3d597dc5 100644 --- a/src/Xbehave.Net40/Xbehave.Net40.csproj +++ b/src/Xbehave.Net40/Xbehave.Net40.csproj @@ -66,7 +66,6 @@ - diff --git a/src/Xbehave.Net40/_.cs b/src/Xbehave.Net40/_.cs index a32de485..ae76ad2e 100644 --- a/src/Xbehave.Net40/_.cs +++ b/src/Xbehave.Net40/_.cs @@ -27,11 +27,11 @@ public static partial class _ [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep Given(string text, Action body) { - return Helper.AddStep("Given " + text, body, StepType.Given); + return new Step("Given " + text, body, StepType.Given); } /// @@ -45,11 +45,11 @@ public static IStep Given(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep When(string text, Action body) { - return Helper.AddStep("When " + text, body, StepType.When); + return new Step("When " + text, body, StepType.When); } /// @@ -63,11 +63,11 @@ public static IStep When(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep Then(string text, Action body) { - return Helper.AddStep("Then " + text, body, StepType.Then); + return new Step("Then " + text, body, StepType.Then); } /// @@ -81,11 +81,11 @@ public static IStep Then(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep And(string text, Action body) { - return Helper.AddStep("And " + text, body, StepType.And); + return new Step("And " + text, body, StepType.And); } /// @@ -99,11 +99,11 @@ public static IStep And(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep But(string text, Action body) { - return Helper.AddStep("But " + text, body, StepType.But); + return new Step("But " + text, body, StepType.But); } /// @@ -117,11 +117,11 @@ public static IStep But(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep Given(string text, Action body) { - return Helper.AddStep("Given " + text, body, StepType.Given); + return new Step("Given " + text, body, StepType.Given); } /// @@ -135,11 +135,11 @@ public static IStep Given(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep When(string text, Action body) { - return Helper.AddStep("When " + text, body, StepType.When); + return new Step("When " + text, body, StepType.When); } /// @@ -153,11 +153,11 @@ public static IStep When(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep Then(string text, Action body) { - return Helper.AddStep("Then " + text, body, StepType.Then); + return new Step("Then " + text, body, StepType.Then); } /// @@ -171,11 +171,11 @@ public static IStep Then(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep And(string text, Action body) { - return Helper.AddStep("And " + text, body, StepType.And); + return new Step("And " + text, body, StepType.And); } /// @@ -189,11 +189,11 @@ public static IStep And(string text, Action body) [SuppressMessage( "Microsoft.Globalization", "CA1303:Do not pass literals as localized parameters", - MessageId = "Xbehave.Helper.AddStep(System.String,System.Action)", + MessageId = "Xbehave.new Step(System.String,System.Action)", Justification = "Text must match method name.")] public static IStep But(string text, Action body) { - return Helper.AddStep("But " + text, body, StepType.But); + return new Step("But " + text, body, StepType.But); } } } diff --git a/src/Xbehave.Net45/Helper.Async.cs b/src/Xbehave.Net45/Helper.Async.cs deleted file mode 100644 index 8000012c..00000000 --- a/src/Xbehave.Net45/Helper.Async.cs +++ /dev/null @@ -1,26 +0,0 @@ -// -// Copyright (c) xBehave.net contributors. All rights reserved. -// - -namespace Xbehave -{ - using System; - using System.Threading.Tasks; - using Xbehave.Sdk; - - internal static partial class Helper - { - public static Fluent.IStep AddStep(string text, Func body, StepType stepType) - { - return new Fluent.Step(CurrentScenario.AddStep(text, body, stepType)); - } - - public static Fluent.IStep AddStep(string text, Func body, StepType stepType) - { - var context = new StepContext(); - var step = CurrentScenario.AddStep(text, () => body(context), stepType); - context.Assign(step); - return new Fluent.Step(step); - } - } -} diff --git a/src/Xbehave.Net45/StringExtensions.Async.cs b/src/Xbehave.Net45/StringExtensions.Async.cs index da073cc1..c261d7b6 100644 --- a/src/Xbehave.Net45/StringExtensions.Async.cs +++ b/src/Xbehave.Net45/StringExtensions.Async.cs @@ -24,7 +24,7 @@ public static partial class StringExtensions /// public static IStep Given(this string text, Func body) { - return Helper.AddStep(text, body, StepType.Given); + return new Step(text, body, StepType.Given); } /// @@ -37,7 +37,7 @@ public static IStep Given(this string text, Func body) /// public static IStep When(this string text, Func body) { - return Helper.AddStep(text, body, StepType.When); + return new Step(text, body, StepType.When); } /// @@ -50,7 +50,7 @@ public static IStep When(this string text, Func body) /// public static IStep Then(this string text, Func body) { - return Helper.AddStep(text, body, StepType.Then); + return new Step(text, body, StepType.Then); } /// @@ -63,7 +63,7 @@ public static IStep Then(this string text, Func body) /// public static IStep And(this string text, Func body) { - return Helper.AddStep(text, body, StepType.And); + return new Step(text, body, StepType.And); } /// @@ -76,7 +76,7 @@ public static IStep And(this string text, Func body) /// public static IStep But(this string text, Func body) { - return Helper.AddStep(text, body, StepType.But); + return new Step(text, body, StepType.But); } /// @@ -93,7 +93,7 @@ public static IStep But(this string text, Func body) public static IStep f(this string text, Func body) { var stepType = StringExtensions.GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// @@ -110,7 +110,7 @@ public static IStep f(this string text, Func body) public static IStep _(this string text, Func body) { var stepType = StringExtensions.GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// @@ -123,7 +123,7 @@ public static IStep _(this string text, Func body) /// public static IStep Given(this string text, Func body) { - return Helper.AddStep(text, body, StepType.Given); + return new Step(text, body, StepType.Given); } /// @@ -136,7 +136,7 @@ public static IStep Given(this string text, Func body) /// public static IStep When(this string text, Func body) { - return Helper.AddStep(text, body, StepType.When); + return new Step(text, body, StepType.When); } /// @@ -149,7 +149,7 @@ public static IStep When(this string text, Func body) /// public static IStep Then(this string text, Func body) { - return Helper.AddStep(text, body, StepType.Then); + return new Step(text, body, StepType.Then); } /// @@ -162,7 +162,7 @@ public static IStep Then(this string text, Func body) /// public static IStep And(this string text, Func body) { - return Helper.AddStep(text, body, StepType.And); + return new Step(text, body, StepType.And); } /// @@ -175,7 +175,7 @@ public static IStep And(this string text, Func body) /// public static IStep But(this string text, Func body) { - return Helper.AddStep(text, body, StepType.But); + return new Step(text, body, StepType.But); } /// @@ -192,7 +192,7 @@ public static IStep But(this string text, Func body) public static IStep f(this string text, Func body) { var stepType = StringExtensions.GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } /// @@ -209,7 +209,7 @@ public static IStep f(this string text, Func body) public static IStep _(this string text, Func body) { var stepType = StringExtensions.GetStepType(text); - return Helper.AddStep(text, body, stepType); + return new Step(text, body, stepType); } } } diff --git a/src/Xbehave.Net45/Xbehave.Net45.csproj b/src/Xbehave.Net45/Xbehave.Net45.csproj index 04800fee..0f0010ad 100644 --- a/src/Xbehave.Net45/Xbehave.Net45.csproj +++ b/src/Xbehave.Net45/Xbehave.Net45.csproj @@ -76,9 +76,6 @@ Fluent\Step.cs - - Helper.cs - IStepContext.cs @@ -114,7 +111,6 @@ -