简而言之,你不能。您只放 get apples的参数的智能感知显示它是Func<T> methodToCreateEachInstance
.
但这并不意味着没有其他方法
Feature: SpecFlowFeature1
In order to help people on StackOverflow
As a helpful soul
I want to discover how to use CreateSet
Scenario: Retreive and filter a table
Given I have some values:
| name | otherinfo | isApple | isOrange | isMango |
| ex1 | someinfo,otherinfo | true | false | false |
| ex2 | someinfo,otherinfo | true | true | true |
Then MyApples should not be empty
在你的绑定中
//using TechTalk.SpecFlow.Assist;
using Should;
public class Example
{
public string name { get; set; }
public string otherInfo { get; set; }
}
[Binding]
public class StepBindings
{
public IEnumerable<Example> MyApples { get; set; }
[Given(@"I have some values:")]
public void GivenIHaveSomeValues(Table table)
{
var onlyApples = table.Rows.Where(x => bool.Parse(x["isApple"]));
MyApples = from x in onlyApples
select new Example
{
name = x["name"],
otherInfo = x["otherInfo"]
};
}
[Then(@"MyApples should not be empty")]
public void ThenMyApplesShouldNotBeEmpty()
{
MyApples.ShouldNotBeNull();
MyApples.ShouldNotBeEmpty();
}
}