From 63181711bc88437ef2d97bff4b7482a4e4982509 Mon Sep 17 00:00:00 2001 From: Gaspar Nagy Date: Thu, 17 Jun 2010 17:04:40 +0200 Subject: [PATCH] [StepTransformation] attribute has been renamed to [StepArgumentTransformation] --- Runtime/Attributes.cs | 18 +++++++++++++++--- Runtime/Bindings/BindingRegistry.cs | 8 ++++---- .../StepArgumentTransformationSteps.cs | 6 +++--- Tests/RuntimeTests/BindingRegistryTest.cs | 2 +- Tests/RuntimeTests/StepTransformationTests.cs | 2 +- changelog.txt | 3 +++ 6 files changed, 27 insertions(+), 12 deletions(-) diff --git a/Runtime/Attributes.cs b/Runtime/Attributes.cs index daa61d07c..1218b6a6a 100644 --- a/Runtime/Attributes.cs +++ b/Runtime/Attributes.cs @@ -111,18 +111,30 @@ public AfterStepAttribute(params string[] tags) : base(BindingEvent.StepEnd, tag } [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] - public class StepTransformationAttribute : Attribute + public class StepArgumentTransformationAttribute : Attribute { public string Regex { get; set; } - public StepTransformationAttribute(string regex) + public StepArgumentTransformationAttribute(string regex) { Regex = regex; } - public StepTransformationAttribute() + public StepArgumentTransformationAttribute() { Regex = "(.*)"; } } + + [Obsolete("this attribute has been renamed to [StepArgumentTransformation]")] + public class StepTransformationAttribute : StepArgumentTransformationAttribute + { + public StepTransformationAttribute(string regex) : base(regex) + { + } + + public StepTransformationAttribute() + { + } + } } \ No newline at end of file diff --git a/Runtime/Bindings/BindingRegistry.cs b/Runtime/Bindings/BindingRegistry.cs index dc4de1dbc..e6be680e1 100644 --- a/Runtime/Bindings/BindingRegistry.cs +++ b/Runtime/Bindings/BindingRegistry.cs @@ -64,9 +64,9 @@ internal void BuildBindingsFromType(Type type) BuildEventBindingFromMethod(method, bindingEventAttr); } - var stepTransformationAttrs = Attribute.GetCustomAttributes(method, typeof(StepTransformationAttribute)); + var stepTransformationAttrs = Attribute.GetCustomAttributes(method, typeof(StepArgumentTransformationAttribute)); if (stepTransformationAttrs != null) - foreach (StepTransformationAttribute stepTransformationAttr in stepTransformationAttrs) + foreach (StepArgumentTransformationAttribute stepTransformationAttr in stepTransformationAttrs) { BuildStepTransformationFromMethod(method, stepTransformationAttr); } @@ -128,9 +128,9 @@ private void BuildStepBindingFromMethod(MethodInfo method, ScenarioStepAttribute stepBindings.Add(stepBinding); } - private void BuildStepTransformationFromMethod(MethodInfo method, StepTransformationAttribute transformationAttribute) + private void BuildStepTransformationFromMethod(MethodInfo method, StepArgumentTransformationAttribute argumentTransformationAttribute) { - StepTransformationBinding stepTransformationBinding = new StepTransformationBinding(transformationAttribute.Regex, method); + StepTransformationBinding stepTransformationBinding = new StepTransformationBinding(argumentTransformationAttribute.Regex, method); stepTransformations.Add(stepTransformationBinding); } diff --git a/Tests/FeatureTests/StepArgumentTransfomation/StepArgumentTransformationSteps.cs b/Tests/FeatureTests/StepArgumentTransfomation/StepArgumentTransformationSteps.cs index 845b7f444..a4a8f7841 100644 --- a/Tests/FeatureTests/StepArgumentTransfomation/StepArgumentTransformationSteps.cs +++ b/Tests/FeatureTests/StepArgumentTransfomation/StepArgumentTransformationSteps.cs @@ -15,7 +15,7 @@ public class Terminal [Binding] public class UserLookup { - [StepTransformation] + [StepArgumentTransformation] public User Transform(string name) { return new User {Name = name}; @@ -25,7 +25,7 @@ public User Transform(string name) [Binding] public class DateConverter { - [StepTransformation("date (.*)")] + [StepArgumentTransformation("date (.*)")] public DateTime Transform(string dateString) { return DateTime.Parse(dateString); @@ -35,7 +35,7 @@ public DateTime Transform(string dateString) [Binding] public class TerminalConverter { - [StepTransformation("terminal (.*)")] + [StepArgumentTransformation("terminal (.*)")] public Terminal Transform(string terminalId) { return new Terminal { Id = terminalId }; diff --git a/Tests/RuntimeTests/BindingRegistryTest.cs b/Tests/RuntimeTests/BindingRegistryTest.cs index 1d1db55c1..bc9a6b410 100644 --- a/Tests/RuntimeTests/BindingRegistryTest.cs +++ b/Tests/RuntimeTests/BindingRegistryTest.cs @@ -13,7 +13,7 @@ public class BindingRegistryTests [Binding] public class StepTransformationExample { - [StepTransformation("BindingRegistryTests")] + [StepArgumentTransformation("BindingRegistryTests")] public int Transform(string val) { return 42; diff --git a/Tests/RuntimeTests/StepTransformationTests.cs b/Tests/RuntimeTests/StepTransformationTests.cs index d71b3b3b3..dd5c2550c 100644 --- a/Tests/RuntimeTests/StepTransformationTests.cs +++ b/Tests/RuntimeTests/StepTransformationTests.cs @@ -13,7 +13,7 @@ public class User [Binding] public class UserCreator { - [StepTransformation("user (w+)")] + [StepArgumentTransformation("user (w+)")] public User Create(string name) { return new User {Name = name}; diff --git a/changelog.txt b/changelog.txt index 3863a46fd..c89815eea 100644 --- a/changelog.txt +++ b/changelog.txt @@ -6,6 +6,9 @@ New features: See examples in Tests/ReportingTests/CustomXsltTemplate.feature + The test error can be accessed through ScenarioContext.Current.TestError (e.g. in an AfterScenario event). ++ [StepTransformation] attribute has been renamed to [StepArgumentTransformation] + because this name describe the intention better. Using the old attribute will + generate a warning. Fixed issues: + NullReference exception when using BeforeTestRun event (Issue 41)