I can not figure out what is used Mock.Verifiable() , if I understand correctly, this code:
var mockContainer = new Mock<CloudBlobContainer>(MockBehavior.Strict, StorageUri); mockContainer.Setup(c => c.GetBlockBlobReference(It.IsAny<string>())) .Returns(mockBlobItem.Object); // ... mockContainer.Verify(c => c.GetBlockBlobReference(It.IsAny<string>()), Times.AtLeastOnce); It will be equivalent to this:
var mockContainer = new Mock<CloudBlobContainer>(MockBehavior.Strict, StorageUri); mockContainer.Setup(c => c.GetBlockBlobReference(It.IsAny<string>())) .Returns(mockBlobItem.Object) .Verifiable(); // ... mockContainer.Verify(); There is a third option:
var mockContainer = new Mock<CloudBlobContainer>(MockBehavior.Strict, StorageUri); mockContainer.Setup(c => c.GetBlockBlobReference(It.IsAny<string>())) .Returns(mockBlobItem.Object); // ... mockContainer.Verify(); I studied many examples, and so the second or third options are used there, as a rule. And there is also .VerifyAll() .
- How to and why?
- What are the features and pitfalls?
- How do these options affect the behavior of Strict and Loose ?
I could not find the documentation for Moq ( except for this inferior one ), does it even exist?