문제

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.

도움이 되었습니까?

해결책

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>>()));
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top