Question on the Reqnroll Sample ReqOverflow #565
-
I am using as a template the Reqnroll sample project ReqOverflow. I am having difficulties getting the ActionAttemptFactory to setup a container with the ErrorMessageProvider and TestLogger instances registered. I slightly changed the TestLogger class to write to a log rather than to console. Where/how does the Sample Reqnroll register the ErrorMessageProvider and TestLogger instances to the IObjectContainer? How does the ActionAttemptFactory get called. Just having a rough time wrapping my mind around how this works. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'm not entirely familiar with that sample, but in looking over the source, I see in the ActionAttempt.cs file that it explicitly implements the // SpecFlow calls this method when the object is created, so you can get
// additional dependencies without passing them through the derived ctor
void IContainerDependentObject.SetObjectContainer(IObjectContainer container)
{
_errorMessageProvider = container.Resolve<ErrorMessageProvider>();
_testLogger = container.Resolve<TestLogger>();
} This method is invoked by the public ActionAttempt<TInput, TResult> Create<TInput, TResult>(string name, Func<TInput, TResult> action)
{
if (name == null) throw new ArgumentNullException(nameof(name));
if (action == null) throw new ArgumentNullException(nameof(action));
var result = new ActionAttempt<TInput, TResult>(action, name);
((IContainerDependentObject)result).SetObjectContainer(_container);
return result; It seems that the The UserAPIDriver class is a class constructor argument to the [Binding] class RegistrationStepDefinitions. So when Reqnroll starts the execution of Also, from a quick search of the code base, I can find no specific spot where an instance of the HTH |
Beta Was this translation helpful? Give feedback.
I'm not entirely familiar with that sample, but in looking over the source, I see in the ActionAttempt.cs file that it explicitly implements the
IContainerDependentObject
interface operation calledSetObjectContainer
. The code withinActionAttempt
looks like this:This method is invoked by …