In some of my unit tests I am trying to return the string passed as a parameter using Moq.
If I ask it to return a specified string such as “home.aspx” it will work.
var navMock = new Mock<INavigationService>();
navMock
.Setup(x => x.GetUrlForSystem(It.IsAny<NavigationService.System>(), It.IsAny<string>()))
.Returns("home.aspx");
However when asking it to return the parameter I receive a
System.Reflection.TargetParameterCountException : Parameter count
mismatch.
var navMock = new Mock<INavigationService>();
navMock
.Setup(x => x.GetUrlForSystem(It.IsAny<NavigationService.System>(), It.IsAny<string>()))
.Returns((string s) => s);
1 Answer