[英]How to shim the Web class from Microsoft.Sharepoint.Client.Web?
I have a function that takes in an argument of type Web (Microsoft.Sharepoint.Client.Web).我有一个 function 接受类型为 Web 的参数(Microsoft.Sharepoint.Client.Web)。 I need to write the test case for the same but unfortunately, ShimWeb is not a thing according to Visual Studio and it suggests me to change it to ShimSPWeb which is not what I am using here.
我需要为此编写测试用例,但不幸的是,根据 Visual Studio,ShimWeb 不是一个东西,它建议我将其更改为 ShimSPWeb,这不是我在这里使用的。 How to fix it?
如何解决?
MY function is as follows:我的function如下:
internal static bool EnsureFolders(string folderAbsolutePath, string folderRelativePath, string listName, ClientContext context, Web targetWeb, List spList)
{
bool folderExists = false;
Folder folder = null;
folder = targetWeb.GetFolderByServerRelativeUrl(folderAbsolutePath);
context.Load(folder);
// .... something else to be done
}
Thanks in advance.提前致谢。
My unit test function is:我的单元测试 function 是:
[TestMethod]
public void EnsureFolders_ShouldConfirmExistenceOrCreateFolders()
{
using (ShimsContext.Create())
{
ShimWeb.AllInstances.GetFolderByServerRelativeUrlString(arg) => {}; // this line throws in errors like I mentioned above.
}
}
Need to add Microsoft.SharePoint.Client.Runtime
dll to the references and use需要将
Microsoft.SharePoint.Client.Runtime
dll添加到引用中并使用
ShimClientRuntimeContext.AllInstances.LoadOf1M0ExpressionOfFuncOfM0ObjectArray<ListItem>((sender, a, b) => { // Something to be done });
for the shim purpose用于垫片目的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.