Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default implementation does not pick negative numbers #246

Closed
sloncho opened this issue Oct 22, 2012 · 2 comments
Closed

Default implementation does not pick negative numbers #246

sloncho opened this issue Oct 22, 2012 · 2 comments
Assignees
Milestone

Comments

@sloncho
Copy link

sloncho commented Oct 22, 2012

As described here: http://stackoverflow.com/q/13020480/8220

Using SpecFlow, I have this scenario:

Scenario: Amount is not negative
  Given a Validator
  Given a TestData
    And MinimumAmount is -0.01
  When validator is invoked
  Then validator sets validation error

SpecFlow generated the following binding for the MinimumAmount:

[Given]
public void Given_MinimumAmount_is_P0(decimal p0)
{
 ....
}

But when executed, the value passed to the step is 0.01 and not -0.01.

If I change the [Given] attribute to:

[Given(@"MinimumAmount is (.*)")]

It works as expected.

@samholder
Copy link
Contributor

@samholder samholder self-assigned this Jul 16, 2015
samholder added a commit to samholder/SpecFlow that referenced this issue May 17, 2016
… as arguments when using regexless methods. The underlyinh problem was that when using regexless parameters a regex is generated, and this regex was using '\W' between any words in the method name. this matches anything which is not a-zA-Z0-9_, which includes the '-' character which is part of the negative number. As I think that we are really matching gaps between words I have changed this to use '\s' which simply matches any whitespace characters. We could instead explictily use the non-word match and add the '-' character if we change it to '[^a-zA-Z0-9-]'. Both make the test pass, but the withspace one seems better to me. Any input appreciated.

This area does not contain any unit tests, but I have added an integration test which checks this, and based it on the scenario in the issue which this fixes, SpecFlowOSS#246

I might be able to add some unit tests in the future, but this seems sufficient for now.
@lock
Copy link

lock bot commented Jul 9, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants