I watched this Introduction to Moq video on Dimecasts.net. In the video, when the guy sets up his moq test, he has the following code:
[Test]
public void TestWithMock()
{
var mockEmailService = new Mock<IEmailService>();
mockEmailService.Expect(x =>
x.SendEmail(It.IsAny<string>,It.IsAny<string>)).Returns(true);
var emailer = new Emailer(mockEmailService.Object);
emailer.SendBatchEmails();
}
Here are my questions:
1) Does moq loop through all different types of strings testing the SendBatchEmails method? I guess I am a little confused on how mocking works.
2) Can someone explain the lambda syntax of the Expect part?
3) The author first had "","" in the SendEmail function, but that failed, so he instead put
It.IsAny<string>
, but I am still unclear on why it failed with "","".
Stackoverflow is not putting the string keyword in the angle brackets. (Fixed)