How to mock a method call that takes a dynamic object

后端 未结 3 1459
悲哀的现实
悲哀的现实 2021-01-11 15:04

Say I have the following:

public interface ISession 
{
   T Get(dynamic filter); }
}

And I have the following code that I want to

3条回答
  •  执念已碎
    2021-01-11 15:57

    Moq provided It.IsAny for that case

    sessionMock.Setup(x => x.Get(It.IsAny()).Returns(new User());
    
    
    

    *dynamic is any object

    提交回复
    热议问题