Moq: Verify a Method is Called


/ Published in: C#
Save to your folder(s)

The code to verify that a method was called.
The this.mockProvider.Verify verifies that GetBiAutoProcessConfigByKeys is called.


Copy this code and paste it in your HTML
  1. [TestMethod]
  2. public void GetProcessConfigSettingsByKeys_Test()
  3. {
  4. // Setup
  5. this.mockProvider.Setup(x => x.GetBiAutoProcessConfigByKeys(123, 456, It.IsAny<int>()))
  6. .Returns(automationConfigurationSetting)
  7. .Verifiable();
  8.  
  9. // Action
  10. var result = target.GetProcessConfigSettingsByKeys(123, 456, null);
  11.  
  12.  
  13. // Assert
  14. this.mockProvider.Verify(x => x.GetBiAutoProcessConfigByKeys(123, 456, null));
  15.  
  16.  
  17. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.