Return any string?

41 views
Skip to first unread message

Hui Zhao

unread,
Nov 5, 2015, 10:34:20 AM11/5/15
to moq...@googlegroups.com
I have the code:
 var callInfoMock = new Mock<ICallInfo>();
  var callInfo = callInfoMock.Object;
  callInfoMock.SetupGet(x => x.LanguageCode).Returns("1");
The language can be "0", "1" or "2" or whatever.
I want to use any string, so  I used
callInfoMock.SetupGet(x => x.LanguageCode).Returns(It.IsAny<string>);

However I found the language code is null. Is there a way to get rid of it?

Thanks 

Vicenç Garcia

unread,
Nov 5, 2015, 10:41:40 AM11/5/15
to moq...@googlegroups.com
I think It.IsAny is meant to be used when you verify the behaviour of the mock. I recommend you to setup the mock to return a proper string.

--
--
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com
---
You received this message because you are subscribed to the Google Groups "Moq Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moqdisc+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages