c# - Assert a method is called with MSTEST - Stack Overflow
stackoverflow.com › questions › 17957263Jul 30, 2013 · This means taking a look at what your method does and writing a test ot maker certain that the data it changes really is changed. For example: public void Bigmethod () { newUpCollections (); CreateDatabaseConnection (); FlagBadData (); } If you wanted to verify that newUpCollections works: [TEST] public void BigMethod_WhenCalled_RecreatesCollections () { BigMethod () Assert.IsNotNull (Class.Collections); }
Mockito: How to Verify That a Method Got Called | Carey ...
careydevelopment.us › blog › mockito-how-to-verifyJan 4, 2022 · In the example above, it's: Mockito.verify(loginService) because the code needs to check the LoginService spy to ensure that a specific method got called. Which method? Well that's what you see after the second period: Mockito.verify(loginService).saveInSession. It's the saveInSession() method. But that method accepts a parameter. It's a Customer object. So you need to specify that it got called with any Customer object. That's sufficient for the purposes of this test. And here's what that ...