Using Specflow's basic dependency injection, it is possible to inject a dynamic context object as below.
This saves having to use the dictionary which I find clunky, are there drawbacks to this approach?
public class TestClass
{
private readonly dynamic context;
public TestClass(ExpandoObject context)
{
this.context = context;
}
[Given(@"I have a file")]
public void GivenIHaveAFile()
{
context.FilePath = @".\Folder\File";
}
[When(@"I use the file")]
public void GivenIHaveAFile()
{
var fileContents = File.ReadAllText(context.FilePath);
}
}