c# - Verify a method call using Moq - Stack Overflow
stackoverflow.com › questions › 9136674Feb 4, 2012 · Verify a method call using Moq. I am fairly new to unit testing in C# and learning to use Moq. Below is the class that I am trying to test. class MyClass { SomeClass someClass; public MyClass (SomeClass someClass) { this.someClass = someClass; } public void MyMethod (string method) { method = "test" someClass.DoSomething (method); } } class Someclass { public DoSomething (string method) { // do something...
moq Tutorial => Validating call order with MockSequence
riptutorial.com › moq › exampleMoq provides support for validating call order using MockSequence, however it only works when using Strict mocks. So, Given the following method to test: public void MethodToTest () { _utility.Operation1 ("1111"); _utility.Operation2 ("2222"); _utility.Operation3 ("3333"); } It can be tested as follows: // Create the mock, not MockBehavior.Strict tells the mock how to behave var utilityMock = new Mock<IUtility> (MockBehavior.Strict); // Create the MockSequence to validate the call order var ...