Question

Please suggest how to mock the dialog box of the following type inside the unit test using moq.

void ShowDialog(string windowName, string parentWindowName, 
  Dictionary<string, object> inputFields, 
  Action<Dictionary<string, object>> closeCallBack, 
  Dictionary<string, object> windowProperties = null);

I have tried the following thing but its not working :

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>>));   

I think I am missing the syntax.

Was it helpful?

Solution

The It.IsAny<T>() call is a method so needs parentheses after it:

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>>()));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top