Combining SpecFlow table and Moq mocked object
- by Confused
I have a situation where I want to use a mocked object (using Moq) so I can create setup and expectations, but also want to supply some of the property values using the SpecFlow Table. Is there a convenient way to create a mock and supply the table for the seed values?
// 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?
}