SPEmulator和Microsoft Fakes

Mau*_*bon 7 sharepoint unit-testing shim microsoft-fakes

嗨,我正在尝试运行一个简单的测试,取代每个的Features.Count SPSite,但我不能.你能帮助我吗?

我有这个代码:

[TestMethod]
public void AllInstances()
{
    using (var context = new SPEmulationContext(IsolationLevel.Fake))
    {
        ShimSPSite.AllInstances.FeaturesGet = (item) =>
        {
            return new ShimSPFeatureCollection()
            {
                CountGet = () => 1
            }.Instance;
        };
        var tSite = new SPSite("http://fakesite");
        Assert.AreEqual(1, tSite.Features.Count);

    }
}
Run Code Online (Sandbox Code Playgroud)

但它失败了这个例外:

Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotImplementedException:抛出了类型'Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotImplementedException'的异常.

这个类似的工作正常

[TestMethod]
public void Shim()
{
    using (var context = new SPEmulationContext(IsolationLevel.Fake))
    {
        var tSite = new ShimSPSite()
        {
            FeaturesGet = () =>
            {
                return new ShimSPFeatureCollection()
                {
                    CountGet = () => 1
                }.Instance;
            }
        }.Instance;
        Assert.AreEqual(1, tSite.Features.Count);
    } 
}
Run Code Online (Sandbox Code Playgroud)

你能告诉我我做错了什么吗?谢谢