以上是我的模拟存储库的设置,用于取回Office365 powershellsessions。 模拟定义似乎很好
var mockOfficeRepository = new Mock<IOffice365PowerShellSessionRepository>();
var mockMongoCol= new Mock<IMongoCollection<Office365PowerShellSession>>();
mockOfficeRepository.Setup(o => o.Where(
shellSession =>
shellSession.OrganizationId == "12" &&
shellSession.Status == Office365PowerShellSessionStatus.Enabled &&
shellSession.IsBackgroundTask == false, null, null, null)).Returns(mockMongoCol.Object.AsQueryable());
但是当我这样称呼它时:
var result = Office365PowerShellSessionRepository.Where(
shellSession =>
shellSession.OrganizationId == selectedOrganizationId &&
shellSession.Status == Office365PowerShellSessionStatus.Enabled &&
shellSession.IsBackgroundTask == false, null, null, null);
var session = result.SingleOrDefault();
它返回null,如果我将其设置为严格行为,则表示它不匹配,即使selectedOrganizationId设置为“ 12”
帮助?