我有一种情况,我想使用一个模拟对象(使用 Moq),这样我就可以创建设置和期望,但也想使用 SpecFlow 表提供一些属性值。有没有一种方便的方法来创建一个模拟并为种子值提供表格?
// Specflow feature
Scenario Outline: MyOutline
Given I have a MyObject object as
| Field | Value |
| Title | The Title |
| Id | The Id |
// Specflow step code
Mock<MyObject> _myMock;
[Given(@"I have a MyObject object as")]
public void GivenIHaveAMyObjectObjectAs(Table table)
{
var obj = table.CreateInstance<MyObject>();
_myMock = new Mock<MyObject>();
// How do I easily combine the two?
}