如何从 Microsoft.Sharepoint.Client.Web 填充 Web class?
How to shim the Web class from Microsoft.Sharepoint.Client.Web?
我有一个函数接受 Web 类型的参数 (Microsoft.Sharepoint.Client.Web)。我需要为此编写测试用例,但不幸的是,根据 Visual Studio,ShimWeb 不是一个东西,它建议我将它更改为 ShimSPWeb,这不是我在这里使用的。如何解决?
我的功能如下:
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
}
提前致谢。
我的单元测试函数是:
[TestMethod]
public void EnsureFolders_ShouldConfirmExistenceOrCreateFolders()
{
using (ShimsContext.Create())
{
ShimWeb.AllInstances.GetFolderByServerRelativeUrlString(arg) => {}; // this line throws in errors like I mentioned above.
}
}
需要在引用中添加Microsoft.SharePoint.Client.Runtime
dll并使用
ShimClientRuntimeContext.AllInstances.LoadOf1M0ExpressionOfFuncOfM0ObjectArray<ListItem>((sender, a, b) => { // Something to be done });
用于垫片目的
我有一个函数接受 Web 类型的参数 (Microsoft.Sharepoint.Client.Web)。我需要为此编写测试用例,但不幸的是,根据 Visual Studio,ShimWeb 不是一个东西,它建议我将它更改为 ShimSPWeb,这不是我在这里使用的。如何解决?
我的功能如下:
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
}
提前致谢。
我的单元测试函数是:
[TestMethod]
public void EnsureFolders_ShouldConfirmExistenceOrCreateFolders()
{
using (ShimsContext.Create())
{
ShimWeb.AllInstances.GetFolderByServerRelativeUrlString(arg) => {}; // this line throws in errors like I mentioned above.
}
}
需要在引用中添加Microsoft.SharePoint.Client.Runtime
dll并使用
ShimClientRuntimeContext.AllInstances.LoadOf1M0ExpressionOfFuncOfM0ObjectArray<ListItem>((sender, a, b) => { // Something to be done });
用于垫片目的