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 ...
c# - Moq testing void method - Stack Overflow
stackoverflow.com › questions › 15062403Aug 16, 2016 · Moq for the IAdd interface is: Mock<IAdd> mockadd = new Mock<IAdd> (); mockadd.Setup (x => x.add (It.IsAny<int> (), It.IsAny<int> ()).callback ( (int a, int b) => { a+b;}); IAdd testing = mockadd.Object; Since the add method is void, it doesn't return any value to Assert with. How can I assert this setup? c# unit-testing nunit moq Share