Reputation: 858
I have created the mock setup for the dialog box of type:
void ShowDialog(string windowName,
string parentWindowName,
Dictionary<string, object> inputFields,
Action<Dictionary<string, object>> closeCallBack,
Dictionary<string, object> windowProperties = null);
like:
UIServicemock.Setup(u => u.ShowDialog(It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Dictionary<string, object>>(),
It.IsAny<Action<Dictionary<string, object>>>(),
It.IsAny<Dictionary<string, object>>())).Callback(ViewName.UnlockScriptPassswordDialog,
StudioViewName.MainWindow,
passwordDictionary, ,
null);
Now in the second last parameter I don't know how to pass the argument so that the dialog box can call the another method.
My function call is like this:
uiService.ShowDialog(ViewName.UnlockScriptPassswordDialog,
StudioViewName.MainWindow,
passwordDictionary,
this.OnUnlockScriptSetCallBack, null);
And this is calling OnUnlockScriptSetCallBack
method.
Upvotes: 1
Views: 371
Reputation: 23747
If I understand you right you want the call to ShowDialog
to invoke the fourth parameter to the method. Set it up like this:
UIServicemock.Setup(
u =>
u.ShowDialog(It.IsAny<string>(),
It.IsAny<string>(),
It.IsAny<Dictionary<string, object>>(),
It.IsAny<Action<Dictionary<string, object>>>(),
It.IsAny<Dictionary<string, object>>()))
.Callback<string,
string,
Dictionary<string, object>,
Action<Dictionary<string, object>>,
Dictionary<string, object>>(
(windowName,
parentWindowName,
inputFields,
closeCallBack,
windowProperties) =>
closeCallBack(windowProperties /* or whatever dictionary should go here*/)
);
This way the parameters passed to ShowDialog
are sent to the Action
given to the Callback
method. When ShowDialog
is invoked, the Action<Dictionary<string, object>>
given as closeCallBack
will be invoked.
Upvotes: 3