c# - Mock an update method returning a void with Moq - Stack ...
stackoverflow.com › questions › 15805812Apr 4, 2013 · Mock an update method returning a void with Moq. In my test, I defined as data a List<IUser> with some record in. I'd like setup a moq the methode Update, this method receive the user id and the string to update. namespace Tests.UnitTests { [TestClass] public class UsersTest { public IUsers MockUsersRepo; readonly Mock<IUsers> _mockUserRepo = new Mock<IUsers> (); private List<IUser> _users = new List<IUser> (); [TestInitialize ()] public void MyTestInitialize () { _users = new ...
Verify Method - Moq Documentation
documentation.help › Moq › 83A8591CAfter the mock is used, a Verify () call is issued on the mock to ensure the method in the setup was invoked: Copy C# var mock = new Mock<IWarehouse> (); this .Setup (x => x.HasInventory (TALISKER, 50 )).Verifiable ().Returns ( true ); ... // other test code ... // Will throw if the test code has didn't call HasInventory. this .Verify ();
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...