Using Moq, you can verify that a method has never been called with specific arguments (that is, arguments that satisfy certain predicates) using Times.Never .
But how to verify that how many temporary methods are called, they are always called with certain arguments?
The default is Times.AtLeastOnce .
No Times.Always . Am I missing something? Thanks!
Edit: Last week I sent the offer to the Moq mailing list, but so far it doesn't seem to be moderated. I will post any updates here.
Edit: example. Let's say I'm testing a class that generates XML documents. I want only valid documents to be created. In other words, verify that the writer’s dependency only ever produced valid documents with a valid record number.
should_only_write_valid_xml_documents Mock.Get(this.writer).Verify( w => w.Write( It.Is<XDocument>(doc => XsdValidator.IsValid(doc)), It.Is<int>(n => n < 3)), Times.Always);
source share