Mock Verify() Invocation

后端 未结 2 1811
有刺的猬
有刺的猬 2020-11-27 23:07

I\'m unit testing to see if a method is called.

[Fact]
        public void Can_Save_Project_Changes()
        {
            //Arrange
            var user =          


        
2条回答
  •  暖寄归人
    2020-11-27 23:50

    Try to setup your method like this:

    mockRepo.Setup(m => m.SaveProject(It.IsAny(),It.IsAny())

    And then verify using It.IsAny as well.

    Or just use It.IsAny for the parameters you do not want (or cannot) check properly for some reason. You can also create custom matchers in the later case.

    As mentioned in other comments. The problem is likely to be on the arguments that you have setup you mock to expect.

提交回复
热议问题