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

InvalidOp exception when a 'step' function has the same parameter name as Example name #257

Open
felix-v-net opened this issue Jul 31, 2017 · 0 comments

Comments

@felix-v-net
Copy link

e.g. when i have

var examples = new ExampleTable("Resource", "Existing");

this
                .Given(_ => _.GivenThereIsOnly__existing__ResourceInDatabase(Existing))
                .When(...)
                .Then(...)
                .WithExamples(examples)

if my step function as following:

public async Task GivenThereIsOnly__existing__ResourceInDatabase(TResource resource)

Then name of parameter 'resource' of method 'GivenThereIsOnly__existing__ResourceInDatabase' will conflict with example name 'Resource' in FluentScanner and will result in following:

System.InvalidOperationException occurred
HResult=0x80131509
Message=Sequence contains more than one matching element
Source=
StackTrace:
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable1 source, Func2 predicate)
at TestStack.BDDfy.FluentScanner1.<CreateTitle>b__16_3(<>f__AnonymousType02 i)
at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext() at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source, Int32& length)
at System.Collections.Generic.EnumerableHelpers.ToArray[T](IEnumerable1 source) at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source)
at TestStack.BDDfy.FluentScanner1.<>c__DisplayClass16_0.<CreateTitle>b__0() at TestStack.BDDfy.StepTitle.ToString() at TestStack.BDDfy.Step.get_Title() at TestStack.BDDfy.Reporters.TextReporter.GetStepWithLines(Step s) at System.Linq.Enumerable.SelectEnumerableIterator2.MoveNext()
at System.Collections.Generic.List1..ctor(IEnumerable1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
at TestStack.BDDfy.Reporters.TextReporter.Process(Story story)
at TestStack.BDDfy.Engine.Run()
at TestStack.BDDfy.BDDfyExtensions.BDDfy[TStory](Object testObject, String scenarioTitle, String caller)
at ...

Would be good to add a sort of clearer message to CreateTitle method of FluentScanner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant