SharePoint API测试系列——Records.BypassLocks测试
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/
对于SharePoint中已经是Record的Item,我们想要修改他的属性,这在UI界面是无法完成的:

这时需要通过Records.BypassLocks API来完成。设计一个tool,利用Records.BypassLocks API来修改Recorded Items的属性(这里拿Title举例),界面如下:

代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using Microsoft.SharePoint;
using Microsoft.SharePoint.Utilities;
//Assembly: Microsoft.Office.Policy (in Microsoft.Office.Policy.dll)
using Microsoft.Office.RecordsManagement.RecordsRepository;
using Microsoft.SharePoint.Publishing; namespace BypassLocksTestTool
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void test_button_Click(object sender, EventArgs e)
{
try
{
SPSecurity.RunWithElevatedPrivileges(delegate ()
{
SPSite site = new SPSite(siteURL_textBox.Text);
SPWeb web = site.RootWeb;
SPList list = web.Lists[listTitle_textBox.Text];
SPListItem item = list.Items[];
Records.BypassLocks(item, delegate (SPListItem spListItem)
{
//Do your stuff here.
item["Title"] = itemTitle_textBox.Text;
item.Update();
if (list.Items[].Title == itemTitle_textBox.Text)
{
testResult_richTextBox.Text = "Test result is passed! Now the first item's title is: " + list.Items[].Title;
testResult_richTextBox.Select(, testResult_richTextBox.Text.Length);
testResult_richTextBox.SelectionColor = Color.Green;
}
else
{
testResult_richTextBox.Text = "Test result is failed!";
testResult_richTextBox.Select(, testResult_richTextBox.Text.Length);
testResult_richTextBox.SelectionColor = Color.Red;
}
});
});
}
catch (Exception ex)
{
testResult_richTextBox.Text = ex.ToString();
}
}
}
}
点击Test按钮进行测试,测试结果会回显到界面,如果Title的value完成了修改,则算测试通过;否则算测试失败。
测试通过后,我们去SharePoint中查看Item的属性,结果和我们预期的一样,对应Item的Title属性值已经变为“SuperTylan”:
这就是对于Records.BypassLocks API的使用与测试,它让我们修改locked recorded item的属性与内容成为可能。
SharePoint API测试系列——Records.BypassLocks测试的更多相关文章
- 【转】【iOS测试系列】常用测试小插件的使用
背景介绍 由于iOS系统的限制,在非越狱的自动化测试中无法实现一些常用的功能,比如不同应用之间来回切换.模拟全局的点击事件等等.但是在越狱的环境下,这些限制就不存在了,我们可以利用各种小插件来实现我们 ...
- ASP.NET Web API 2系列(三):查看WebAPI接口的详细说明及测试接口
引言 前边两篇博客介绍了Web API的基本框架以及路由配置,这篇博客主要解决在前后端分离项目中,为前端人员提供详细接口说明的问题,主要是通过修改WebApi HelpPage相关代码和添加WebAp ...
- 「译」JUnit 5 系列:条件测试
原文地址:http://blog.codefx.org/libraries/junit-5-conditions/ 原文日期:08, May, 2016 译文首发:Linesh 的博客:「译」JUni ...
- "Unity测试系列"文章索引
对Unity各种API的细节进行测试 Common 一些Unity基础操作的性能测试 Animation/Animator Animation Play/Stop测试 关于Animation动画事件的 ...
- 前端测试框架Jest系列教程 -- Asynchronous(测试异步代码)
写在前面: 在JavaScript代码中,异步运行是很常见的.当你有异步运行的代码时,Jest需要知道它测试的代码何时完成,然后才能继续进行另一个测试.Jest提供了几种方法来处理这个问题. 测试异步 ...
- Tensorflow object detection API(1)---环境搭建与测试
参考: https://blog.csdn.net/dy_guox/article/details/79081499 https://blog.csdn.net/u010103202/article/ ...
- [转帖]TPC-C解析系列01_TPC-C benchmark测试介绍
TPC-C解析系列01_TPC-C benchmark测试介绍 http://www.itpub.net/2019/10/08/3334/ 学习一下. 自从蚂蚁金服自研数据库OceanBase获得TP ...
- 来自ebay内部的「软件测试」学习资料,覆盖GUI、API自动化、代码级测试及性能测试等,Python等,拿走不谢!...
在软件测试领域从业蛮久了,常有人会问我: 刚入测试一年,很迷茫,觉得没啥好做的-- 测试在公司真的不受重视,我是不是去转型做开发会更好? 资深的测试架构师的发展路径是怎么样的?我平时该怎么学习? 我 ...
- FPGA与simulink联合实时环路系列——实验一 测试
实验一 测试 实验内容 在simulink创建测试模块,通过测试模块产生信号,再传送到FPGA,FPGA读出后再将信号无处理传送回simulink进行显示.由此来测试整个硬件在环的功能是否正常,并且熟 ...
随机推荐
- Lintcode: Search Range in Binary Search Tree
Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Find all t ...
- java多线程实现卖票小程序
package shb.java.demo; /** * 多线程测试卖票小程序. * @Package:shb.java.demo * @Description: * @author shaobn * ...
- DOM事件处理有三个阶段
DOM事件处理有三个阶段: 捕捉阶段(capture phase):从最上层元素,直到最下层(你点击的那个target)元素.路过的所有节点都可以捕捉到该事件. 命中阶段(target phase): ...
- 夺命雷公狗---DEDECMS----25dedecms导航条首页的跳转
我们的导航条首页一直没写跳转,现在我们看看dede自带模版的首页是怎么写的: 他也是封装了一个{dede:global.cfg_cmsurl/}/内置标签来实现的,那么我们来改下我们的head.htm ...
- Android应用开发中的风格和主题(style,themes)
http://www.cnblogs.com/playing/archive/2011/04/01/2002469.html 越来越多互联网企业都在Android平台上部署其客户端,为了提升用户体验, ...
- [python] No module named _sysconfigdata_nd
when setting python environment in Ubuntu13.04, i got this error: ImportError: No module named _sysc ...
- android 自定义view详解
1.自定义View前首先要了解一下View的方法,虽然有些不一定要实现. 分类 方法 描述 创建 Constructors View中有两种类型的构造方法,一种是在代码中构建View,另一种是填充布局 ...
- Subversion简明手册--使用hook svn
使用 hook ,为了方便管理员 控制提交的过程 Subversion 提供了 hook 机制.当特定的 事件发生时,相应的 hook 会被调用, hook 其实就相当于特定 事件的处理函数.每个 h ...
- NOIP201205Vigenère密码
NOIP201205Vigenère密码 [问题描述] 16 世纪法国外交家Blaise de Vigenère设计了一种多表密码加密 ...
- 【转】Web UI自动化测试原理
目前市面上有很多Web UI自动化测试框架,比如WatiN, Selinimu,WebDriver,还有VS2010中的Coded UI等等. 这些框架都可以操作Web中的控件,模拟用户输入,点击等 ...