【问题标题】:How to mole SPGroupCollection如何摩尔 SPGroupCollection
【发布时间】:2011-07-11 22:01:34
【问题描述】:

我写了以下代码,我真的很想测试它:

SPGroupCollection sharePointGroupCollection = contextWeb.Groups;
foreach (SPGroup sharePointGroup in sharePointGroupCollection)
{
    if (groupname == sharePointGroup.Name)
    {
        SPUserCollection sharePointUserCollection = sharePointGroup.Users;
        foreach (SPUser sharePointUser in sharePointUserCollection)
        {
            if (username == sharePointUser.Name)
            {
                return true;
            }
        }
    }
}

问题是我不知道如何破坏 SPGroupCollection 对象。我知道存在 MSPGroupCollection 鼹鼠对象,但我无法将鼹鼠项 (MSPGroup) 集合添加到我的 MSPGroupCollection 集合中。谁能帮我解决这个问题?我想添加三个或四个具有某些名称的 MSPGroup 对象。比我想用三个或四个具有某些名称的 MSPUser 对象设置一个 MSPUserCollection。我该怎么做?

问候,克里斯蒂安

【问题讨论】:

    标签: .net sharepoint moles


    【解决方案1】:

    查看 Moles 文档(位于开始 > Microsoft Moles)。特别是,文档“使用行为对 SharePoint Foundation 进行单元测试”包含一些如何模拟 SharePoint 集合的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-19
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多