Skip to content

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

Description

@felix-v-net

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions