diff --git a/AgentBdd.Specs/AgentBdd.Specs.csproj b/AgentBdd.Specs/AgentBdd.Specs.csproj new file mode 100644 index 0000000..d78bcf8 --- /dev/null +++ b/AgentBdd.Specs/AgentBdd.Specs.csproj @@ -0,0 +1,75 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {35D0BB21-FB1B-4E7C-B05D-6A9A5A5B5C93} + Library + Properties + AgentBdd.Specs + AgentBdd.Specs + v3.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + C:\Program Files (x86)\JetBrains\ReSharper\v5.1\Bin\JetBrains.ReSharper.Feature.Services.dll + + + + + + + + + + + + + + True + True + Creating method names from variables.feature + + + + + + SpecFlowSingleFileGenerator + Creating method names from variables.feature.cs + + + + + {001D4902-AFDE-496F-AFE7-F97A1375D720} + AgentBdd + + + + + \ No newline at end of file diff --git a/AgentBdd.Specs/Creating method names from variables.feature b/AgentBdd.Specs/Creating method names from variables.feature new file mode 100644 index 0000000..f0fd381 --- /dev/null +++ b/AgentBdd.Specs/Creating method names from variables.feature @@ -0,0 +1,15 @@ +Feature: Creating method names from variables + In order to make writiing step definitions easier + As a ReSharper user + I want to be have my step method names suggested as I type my step + + +Scenario Outline: Suggest simple method names + When I provide the step "" + Then it should suggest as the method name + + Examples: + | step description | method name | + | the foo is cool | the_foo_is_cool | + | the foo's bar | the_foos_bar | + | the foo is "(.*)" bar | the_foo_is_bar | diff --git a/AgentBdd.Specs/Creating method names from variables.feature.cs b/AgentBdd.Specs/Creating method names from variables.feature.cs new file mode 100644 index 0000000..cef1e10 --- /dev/null +++ b/AgentBdd.Specs/Creating method names from variables.feature.cs @@ -0,0 +1,91 @@ +// ------------------------------------------------------------------------------ +// +// This code was generated by SpecFlow (http://www.specflow.org/). +// SpecFlow Version:1.3.5.2 +// Runtime Version:4.0.30319.1 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +// ------------------------------------------------------------------------------ +#region Designer generated code +namespace AgentBdd.Specs +{ + using TechTalk.SpecFlow; + + + [System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "1.3.5.2")] + [System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [NUnit.Framework.TestFixtureAttribute()] + [NUnit.Framework.DescriptionAttribute("Creating method names from variables")] + public partial class CreatingMethodNamesFromVariablesFeature + { + + private static TechTalk.SpecFlow.ITestRunner testRunner; + +#line 1 "Creating method names from variables.feature" +#line hidden + + [NUnit.Framework.TestFixtureSetUpAttribute()] + public virtual void FeatureSetup() + { + testRunner = TechTalk.SpecFlow.TestRunnerManager.GetTestRunner(); + TechTalk.SpecFlow.FeatureInfo featureInfo = new TechTalk.SpecFlow.FeatureInfo(new System.Globalization.CultureInfo("en-US"), "Creating method names from variables", "In order to make writiing step definitions easier\r\nAs a ReSharper user\r\nI want to" + + " be have my step method names suggested as I type my step", ((string[])(null))); + testRunner.OnFeatureStart(featureInfo); + } + + [NUnit.Framework.TestFixtureTearDownAttribute()] + public virtual void FeatureTearDown() + { + testRunner.OnFeatureEnd(); + testRunner = null; + } + + public virtual void ScenarioSetup(TechTalk.SpecFlow.ScenarioInfo scenarioInfo) + { + testRunner.OnScenarioStart(scenarioInfo); + } + + [NUnit.Framework.TearDownAttribute()] + public virtual void ScenarioTearDown() + { + testRunner.OnScenarioEnd(); + } + + public virtual void SuggestSimpleMethodNames(string stepDescription, string methodName) + { + TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Suggest simple method names", ((string[])(null))); +#line 7 +this.ScenarioSetup(scenarioInfo); +#line 8 +testRunner.When(string.Format("I provide the step \"{0}\"", stepDescription)); +#line 9 +testRunner.Then(string.Format("it should suggest {0} as the method name", methodName)); +#line hidden + testRunner.CollectScenarioErrors(); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Suggest simple method names")] + public virtual void SuggestSimpleMethodNames_TheFooIsCool() + { + this.SuggestSimpleMethodNames("the foo is cool", "the_foo_is_cool"); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Suggest simple method names")] + public virtual void SuggestSimpleMethodNames_TheFooSBar() + { + this.SuggestSimpleMethodNames("the foo\'s bar", "the_foos_bar"); + } + + [NUnit.Framework.TestAttribute()] + [NUnit.Framework.DescriptionAttribute("Suggest simple method names")] + public virtual void SuggestSimpleMethodNames_TheFooIs_Bar() + { + this.SuggestSimpleMethodNames("the foo is \"(.*)\" bar", "the_foo_is_bar"); + } + } +} +#endregion diff --git a/AgentBdd.Specs/Properties/AssemblyInfo.cs b/AgentBdd.Specs/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d8175ca --- /dev/null +++ b/AgentBdd.Specs/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("AgentBdd.Specs")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("AgentBdd.Specs")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2010")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e895d809-0936-49b0-8351-40de126337d6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AgentBdd.Specs/Steps/SuggestMethodNameSteps.cs b/AgentBdd.Specs/Steps/SuggestMethodNameSteps.cs new file mode 100644 index 0000000..d8b1d81 --- /dev/null +++ b/AgentBdd.Specs/Steps/SuggestMethodNameSteps.cs @@ -0,0 +1,27 @@ +using System.Linq; +using AgentBdd.Macros; +using NUnit.Framework; +using TechTalk.SpecFlow; + +namespace AgentBdd.Specs.Steps +{ + [Binding] + public class SuggestMethodNameSteps + { + string suggestedMethodName; + + [When(@"I provide the step ""(.*)""")] + public void When_I_provide_the_step(string step) + { + suggestedMethodName = new SuggestMethodNameFromVariable().EvaluateQuickResult(null,new []{step}.ToList()); + } + + [Then(@"it should suggest (.*) as the method name")] + public void Then_it_should_sugget_the_method_name(string methodName) + { + Assert.AreEqual(methodName,suggestedMethodName); + } + + + } +} diff --git a/AgentBdd.sln b/AgentBdd.sln index 9a01919..470c5e0 100644 --- a/AgentBdd.sln +++ b/AgentBdd.sln @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgentBdd", "AgentBdd\AgentBdd.csproj", "{001D4902-AFDE-496F-AFE7-F97A1375D720}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgentBdd.Specs", "AgentBdd.Specs\AgentBdd.Specs.csproj", "{35D0BB21-FB1B-4E7C-B05D-6A9A5A5B5C93}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -13,6 +15,10 @@ Global {001D4902-AFDE-496F-AFE7-F97A1375D720}.Debug|Any CPU.Build.0 = Debug|Any CPU {001D4902-AFDE-496F-AFE7-F97A1375D720}.Release|Any CPU.ActiveCfg = Release|Any CPU {001D4902-AFDE-496F-AFE7-F97A1375D720}.Release|Any CPU.Build.0 = Release|Any CPU + {35D0BB21-FB1B-4E7C-B05D-6A9A5A5B5C93}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {35D0BB21-FB1B-4E7C-B05D-6A9A5A5B5C93}.Debug|Any CPU.Build.0 = Debug|Any CPU + {35D0BB21-FB1B-4E7C-B05D-6A9A5A5B5C93}.Release|Any CPU.ActiveCfg = Release|Any CPU + {35D0BB21-FB1B-4E7C-B05D-6A9A5A5B5C93}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/AgentBdd/Macros/SuggestMethodNameFromVariable.cs b/AgentBdd/Macros/SuggestMethodNameFromVariable.cs index 44f9df5..b08d619 100644 --- a/AgentBdd/Macros/SuggestMethodNameFromVariable.cs +++ b/AgentBdd/Macros/SuggestMethodNameFromVariable.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.RegularExpressions; using JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots; using JetBrains.ReSharper.Feature.Services.LiveTemplates.Macros; @@ -18,16 +19,8 @@ public override string EvaluateQuickResult(IHotspotContext context, IList