Hi I'm trying to run a simple test replacing Features.Count on every SPSite
, but I can't. Can you help me?
I have this code:
[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);
}
}
but it fails with this exception:
Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotImplementedException: Exception of type 'Microsoft.QualityTools.Testing.Fakes.Shims.ShimNotImplementedException' was thrown.
This one which is similar works fine
[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);
}
}
Can you tell me what I'm doing wrong? Thanks