简体   繁体   English

Moq安装程序不提供AsQueryable方法

[英]Moq Setup not supplying AsQueryable method

I have the following: 我有以下内容:

        Mock<ISiteRepository> mockSiteRepository = new Mock<ISiteRepository>();

        mockSiteRepository.Setup(m => m.Sites).Returns(new Site[] {
            new Site {
                SiteID = 0,
                DateCreated = DateTime.Now,
                Name = "A",
            }
        }/*There is no AsQueryable ?*/);

Here is my interface wth the implemented thingy: 这是我实现的东西的界面:

public interface ISiteRepository
{
    IQueryable<Site> Sites { get; }
    ...

Any ideas? 有任何想法吗?

If I do not put anything at the end of my Site array, it throws compile error: 如果我没有在我的Site数组的末尾放任何东西,它会抛出编译错误:

Error   6   The best overloaded method match for 'Moq.Language.IReturns<James.Domain.Abstract.ISiteRepository,System.Linq.IQueryable<James.Domain.Entities.Site>>.Returns(System.Linq.IQueryable<James.Domain.Entities.Site>)' has some invalid arguments   

You need to have a using for System.Linq; 你需要using System.Linq; .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM