private void AddUserRole_and_RemoveUserRole(string user, string email, string username, string role) { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string url = Globals.SiteCollectionForCreationTests() + "/UserRoleList"; string[] roles = admin.GetUserRoles(url, user); StringCollection col = new StringCollection(); col.AddRange(roles); if (col.Contains(role)) { admin.RemoveUserRole(url, user, role); roles = admin.GetUserRoles(url, user); col.Clear(); col.AddRange(roles); } Assert.IsFalse(col.Contains(role), "This user must not have contributor rights to start with!"); admin.AddUserRole(url, user, email, username, role); roles = admin.GetUserRoles(url, user); col.Clear(); col.AddRange(roles); Assert.IsTrue(col.Contains(role), "But we just added it!"); admin.RemoveUserRole(url, user, role); roles = admin.GetUserRoles(url, user); col.Clear(); col.AddRange(roles); Assert.IsFalse(col.Contains(role), "But we just removed it!"); }
[Test] public void Test_04_GetUserRoles() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string[] roles = admin.GetUserRoles(Globals.SiteCollectionForCreationTests(), @"WSDEV\lnpair"); Assert.IsTrue(roles.Length == 2, "The user is both a Reader and a Contributor"); StringCollection roleList = new StringCollection(); roleList.AddRange(roles); Assert.IsTrue(roleList.Contains("Read"), @"WSDEV\lnpair is a Reader on this site. Really!"); Assert.IsTrue(roleList.Contains("Contribute"), @"WSDEV\lnpair is a Contributor on this site. Really!"); }
[Test] public void Test_02_CreateSite_and_DeleteItem() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string siteForCreation = Globals.SiteCollectionForCreationTests() + "/SiteToDelete"; Assert.IsFalse(Helper_SiteExists(siteForCreation), siteForCreation+" must not exist before the test is run! Delete it!"); admin.CreateSite(siteForCreation, "Test Site - Delete This", "Delete this is you see it", "Team Site"); Assert.IsTrue(Helper_SiteExists(siteForCreation), siteForCreation+" was just created! So where is it then? Hmm?"); admin.DeleteItem(siteForCreation); Assert.IsFalse(Helper_SiteExists(siteForCreation), " So why has "+siteForCreation+" not been deleted then?"); }
[Test] public void Test_03_ListUsers() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string[] users = admin.ListUsers(Globals.SiteCollectionForCreationTests()); Assert.IsTrue(users.Length == 2, "There are two users in the list."); StringCollection userList = new StringCollection(); for(int i = 0; i < users.Length; ++i) { userList.Add(users[i]); } Assert.IsTrue(userList.Contains(@"WSDEV\lnpair"), "Contributor user is missing."); Assert.IsTrue(userList.Contains(@"UK\iainb"), "Contributor user is missing."); }
[Test] public void Test_01_ListAvailableSiteTemplates() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string[] templates = admin.ListAvailableSiteTemplates(Globals.SiteCollectionForTests()); StringCollection tpls = new StringCollection(); tpls.AddRange(templates); Assert.IsTrue(tpls.Contains("Team Site"), "Template is missing: Team Site"); Assert.IsTrue(tpls.Contains("Blank Site"), "Template is missing: Blank Site"); Assert.IsTrue(tpls.Contains("Document Workspace"), "Template is missing: Document Workspace"); Assert.IsTrue(tpls.Contains("Basic Meeting Workspace"), "Template is missing: Basic Meeting Workspace"); Assert.IsTrue(tpls.Contains("Blank Meeting Workspace"), "Template is missing: Blank Meeting Workspace"); Assert.IsTrue(tpls.Contains("Decision Meeting Workspace"), "Template is missing: Decision Meeting Workspace"); Assert.IsTrue(tpls.Contains("Social Meeting Workspace"), "Template is missing: Social Meeting Workspace"); Assert.IsTrue(tpls.Contains("Multipage Meeting Workspace"), "Template is missing: Multipage Meeting Workspace"); }
[Test] public void Test_08_CreateFolder() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string url = Globals.SiteCollectionForCreationTests()+"/TestSharedDocs"; string folderUrl = url +"/Folder"; if (Helper_DocLibExists(url)) admin.DeleteItem(url); admin.CreateDocumentLibrary(url, "Microsoft Word document"); Assert.IsFalse(Helper_FolderExists(folderUrl), string.Format("That folder shouldn't exist yet.")); Assert.IsTrue(Helper_DocLibExists(url), string.Format("We have just created {0}. Why doesn't it exist?", url)); admin.CreateFolder(folderUrl); Assert.IsTrue(Helper_FolderExists(folderUrl), string.Format("That folder should exist now.")); admin.DeleteItem(folderUrl); admin.DeleteItem(url); }
[Test] public void Test_07_CreateDocumentLibrary() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string url = Globals.SiteCollectionForCreationTests()+"/TestSharedDocs"; if (Helper_DocLibExists(url)) admin.DeleteItem(url); Assert.IsFalse(Helper_DocLibExists(url), string.Format("There is an undeletable document library at: {0}. Please delete it and re-run the test.", url)); admin.CreateDocumentLibrary(url, "Microsoft Word document"); Assert.IsTrue(Helper_DocLibExists(url), string.Format("We have just created {0}. Why doesn't it exist?", url)); admin.DeleteItem(url); }
[Test] public void Test_06_ListAvailableDocumentLibraryTemplates() { Proxy.AdminRef.Admin admin = new Proxy.AdminRef.Admin( ); admin.Url = Globals.AdminUrl(); admin.Credentials = System.Net.CredentialCache.DefaultCredentials.GetCredential(new Uri(Globals.SharePointTestServer), ""); string url = Globals.SiteCollectionForCreationTests(); string[] templates = admin.ListAvailableDocumentLibraryTemplates(url); StringCollection coll = new StringCollection(); coll.AddRange(templates); //Assert.IsTrue(coll.Count == 8, "Wrong number of templates returned!"); Assert.IsTrue(coll.Contains("None"), "Failed to find template: None"); //Assert.IsTrue(coll.Contains("Microsoft Office Word document"), "Failed to find template: Microsoft Office Word document"); // SharePoint2007 library template name Assert.IsTrue(coll.Contains("Microsoft Word document"), "Failed to find template: Microsoft Office Word document"); // SharePoint2010 library template name Assert.IsTrue(coll.Contains("Microsoft SharePoint Designer Web page"), "Failed to find template: Microsoft Office FrontPage Web page"); Assert.IsTrue(coll.Contains("Microsoft Excel spreadsheet"), "Failed to find template: Microsoft Office Excel spreadsheet"); Assert.IsTrue(coll.Contains("Microsoft PowerPoint presentation"), "Failed to find template: Microsoft Office PowerPoint presentation"); Assert.IsTrue(coll.Contains("Basic page"), "Failed to find template: Basic page"); Assert.IsTrue(coll.Contains("Web Part page"), "Failed to find template: Web Part page"); Assert.IsTrue(coll.Contains("Basic page"), "Failed to find template: Basic page"); }