Skip to content

Commit

Permalink
[StepTransformation] attribute has been renamed to [StepArgumentTrans…
Browse files Browse the repository at this point in the history
…formation]
  • Loading branch information
gasparnagy committed Jun 17, 2010
1 parent ca74597 commit 6318171
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 12 deletions.
18 changes: 15 additions & 3 deletions Runtime/Attributes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
}
}
}
8 changes: 4 additions & 4 deletions Runtime/Bindings/BindingRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Terminal
[Binding]
public class UserLookup
{
[StepTransformation]
[StepArgumentTransformation]
public User Transform(string name)
{
return new User {Name = name};
Expand All @@ -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);
Expand All @@ -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 };
Expand Down
2 changes: 1 addition & 1 deletion Tests/RuntimeTests/BindingRegistryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class BindingRegistryTests
[Binding]
public class StepTransformationExample
{
[StepTransformation("BindingRegistryTests")]
[StepArgumentTransformation("BindingRegistryTests")]
public int Transform(string val)
{
return 42;
Expand Down
2 changes: 1 addition & 1 deletion Tests/RuntimeTests/StepTransformationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
3 changes: 3 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6318171

Please sign in to comment.