给出以下界面:
public interface IApiHelper { dynamic CallApi(string url); }
我已经宣布了一个实例化的a Mock
我正在尝试编写一个返回Success = true属性的测试,以模仿JSON结果.我的设置如下:
_apiHelperMock.Setup(o => o.CallApi(It.IsAny())).Returns((dynamic)new { Success = true });
但是,在尝试运行测试时出现以下错误: Moq.Language.Flow.ISetup'不包含"返回"的定义
谁能告诉我这里我做错了什么?
我能够创建ExpandoObject
并投射到它object
.
dynamic userInfo = new ExpandoObject(); dynamic user1 = new ExpandoObject(); user1.title = "aaa"; dynamic user2 = new ExpandoObject(); user2.title = "bbb"; userInfo.groups = new List{ user1 , user2 }; var endpointMock = new Mock (); endpointMock.Setup(c => c.RequestJsonDynamicGet(It.IsAny ())).Returns((object)userInfo);