Verify a method is called or not in Unit Test

LicenseManagerService.Verify(m => m.LoadProductLicenses(),Times.Once);

By calling the LicenseManagerService property, you’re creating a new mock object. Naturally, no invocations have ever been performed on this instance.

You should change this property’s implementation to return the same instance every time it is called.

Leave a Comment