2011-07-11 56 views
0

我寫了下面的代碼,我真的想測試一下:如何去痣SPGroupCollection

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 mole對象,但我無法將moled Items(MSPGroup)的集合添加到我的MSPGroupCollection集合中。任何人都可以幫我解決這個問題嗎?我想添加三個或四個具有某個名稱的MSPGroup對象。比我想用三個或四個具有某個名稱的MSPUser對象設置MSPUserCollection。我怎樣才能做到這一點?

親切的問候,基督教

回答

1

看看痣文件(位於開始>微軟摩爾)。特別是,「單元測試帶有行爲的SharePoint Foundation」文檔包含一些如何模擬SharePoint集合的示例。