我需要从谷歌日历api模拟一个方法。但它每次都会出错。我有以下代码。
DateTime dateTimeNow = new DateTime(2018, 10, 10, 10, 10, 10);
Event events = new Event
{
Id = "EventA",
Summary = "Summary",
Description = "Desc",
Start = new EventDateTime { Date = "2018-10-10", DateTime = dateTimeNow},
End = new EventDateTime { Date = "2018-10-10", DateTime = dateTimeNow.AddHours(1) },
};
Mock<CalendarService> fakeCalendarService = new Mock<CalendarService>();
fakeCalendarService
.Setup(x => x.Events.Insert(It.IsAny<Event>(), It.IsAny<string>()).Execute())
.Returns(events);
我收到以下错误消息:
Message: System.NotSupportedException : Invalid setup on a non-virtual (overridable in VB) member: x => x.Events.Insert(It.IsAny<Event>(), It.IsAny<String>()).Execute()
我能够模拟其他功能但是这个功能:
_service.Events.Insert(newEvent, _calendarId).Execute();
后面有.Execute()。由于这个陈述,我不知道如何嘲笑它。