Verifying generic method called using Moq

后端 未结 2 1484
無奈伤痛
無奈伤痛 2021-01-17 18:12

I\'m having trouble verifying that mock of IInterface.SomeMethod(T arg) was called using Moq.Mock.Verify.

I\'m can verify that met

2条回答
  •  孤独总比滥情好
    2021-01-17 18:35

    I'm going to wing it. Since GenericMethod requires that a T argument be provided, would it be possible to do:

    mockInterface.Verify(serviceInterface => serviceInterface.GenericMethod(It.Is(x=> typeof(ISpecificCommand).IsAssignableFrom(x.GetType()))), Times.Once());
    
        

    提交回复
    热议问题