public static CompareStringArrays ( string str1, string str2 ) : bool | ||
str1 | string | The first string array to be compared. |
str2 | string | The second string array to be compared. |
Результат | bool |
public void MSSITESS_S02_TC06_CreateWebWithZeroFalse() { #region Variables string subSiteToBeCreated = this.newSubsite; string url = Common.GetConfigurationPropertyValue(Constants.SiteName, this.Site) + "/" + subSiteToBeCreated; string title = Constants.WebTitle; string description = Constants.WebDescription; string templateName = string.Empty; uint language = 0; bool languageSpecified = true; uint locale = 0; bool localeSpecified = true; uint collationLocale = 0; bool collationLocaleSpecified = true; bool uniquePermissions = false; bool uniquePermissionsSpecified = true; bool anonymous = false; bool anonymousSpecified = true; bool presence = false; bool presenceSpecified = true; Template[] templateList; uint localeId = uint.Parse(Common.GetConfigurationPropertyValue(Constants.ValidLCID, this.Site)); #endregion Variables Site.Assume.IsTrue(Common.IsRequirementEnabled(3781, this.Site), @"Test is executed only when R3781Enabled is set to true."); // Initialize the web service with an authenticated account. this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated); // Invoke the GetSiteTemplates operation with valid parameters. this.sitessAdapter.GetSiteTemplates(localeId, out templateList); // GetTemplate operation should return more than one template. Site.Assert.IsTrue(templateList.Length > 1, "GetTemplate operation should return more than one template."); // The first template is a Global template and can't be used to create web ,so templateList[1] is used here. templateName = templateList[1].Name; // Create web with language, locale, collationLocale zero and uniquePermissions, anonymous, presence false. this.sitessAdapter.CreateWeb(url, title, description, templateName, language, languageSpecified, locale, localeSpecified, collationLocale, collationLocaleSpecified, uniquePermissions, uniquePermissionsSpecified, anonymous, anonymousSpecified, presence, presenceSpecified); Site.Log.Add(LogEntryKind.Comment, "CreateWeb succeed!"); #region Capture requirements // Get a string contains the name and value of the expected properties of the created web. string webPropertyDefault = this.sutAdapter.GetWebProperties(Common.GetConfigurationPropertyValue(Constants.SiteName, this.Site), subSiteToBeCreated); //// Get each property value by splitting the string. Dictionary <string, string> properties = AdapterHelper.DeserializeWebProperties(webPropertyDefault, Constants.ItemSpliter, Constants.KeySpliter); uint languageActual = uint.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyLanguage, this.Site)]); uint defaultLanguage = uint.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyDefaultLanguage, this.Site)]); uint localeActual = uint.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyLocale, this.Site)]); uint defaultLocale = uint.Parse(Common.GetConfigurationPropertyValue(Constants.DefaultLCID, this.Site)); string permissionActual = properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyUserNameInPermissions, this.Site)]; string[] userNameActual = permissionActual.Split(','); bool anonymousActual = bool.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyAnonymous, this.Site)]); // Get a string contains the name and value of the expected properties of the parent web of the created web. string webParentDefault = this.sutAdapter.GetWebProperties(Common.GetConfigurationPropertyValue(Constants.SiteName, this.Site), string.Empty); //// Get each property value by splitting the string. Dictionary <string, string> parentProperties = AdapterHelper.DeserializeWebProperties(webParentDefault, Constants.ItemSpliter, Constants.KeySpliter); string parentPermission = parentProperties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyUserNameInPermissions, this.Site)]; string[] userNameExpected = parentPermission.Split(','); // If language is zero, R552 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R552"); // Verify MS-SITESS requirement: MS-SITESS_R552 Site.CaptureRequirementIfAreEqual <uint>( defaultLanguage, languageActual, 552, @"[In CreateWeb] [language:] If zero, the subsite to be created MUST use the server’s default language for the user interface."); // If locale is zero, R553 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R553"); // Verify MS-SITESS requirement: MS-SITESS_R553 Site.CaptureRequirementIfAreEqual <uint>( defaultLocale, localeActual, 553, @"[In CreateWeb] [locale:] If zero, specifies that the subsite to be created MUST use the server’s default settings for displaying data."); // If uniquePermissions is false, R519 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R519", userNameActual); // Verify MS-SITESS requirement: MS-SITESS_R519 bool isVerifyR519 = AdapterHelper.CompareStringArrays(userNameExpected, userNameActual); Site.CaptureRequirementIfIsTrue( isVerifyR519, 519, @"[In CreateWeb] [uniquePermissions:] If set to false, the subsite to be created MUST inherit its permissions from its parent site."); // If anonymous is false, R521 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R521", anonymousActual); // Verify MS-SITESS requirement: MS-SITESS_R521 Site.CaptureRequirementIfIsFalse( anonymousActual, 521, @"[In CreateWeb] [anonymous:] If set to false, the anonymous authentication MUST NOT be allowed for the subsite to be created."); // Verify that Microsoft SharePoint Foundation 2010 and above support operation CreateWeb. this.VerifyOperationCreateWeb(); #endregion Capture requirements // If R3781 is not enabled, that means the CreateWeb operation is not supported, so there is no web to be deleted here. if (Common.IsRequirementEnabled(3781, this.Site) && Common.IsRequirementEnabled(3791, this.Site)) { this.sitessAdapter.DeleteWeb(url); Site.Log.Add(LogEntryKind.Comment, "DeleteWeb succeed!"); #region Capture requirements //// Verify that Microsoft SharePoint Foundation 2010 and above support operation DeleteWeb. this.VerifyOperationDeleteWeb(); #endregion Capture requirements } }
public void MSSITESS_S04_TC01_ExportSolutionSucceed() { Site.Assume.IsTrue(Common.IsRequirementEnabled(5301, this.Site), @"Test is executed only when R5301Enabled is set to true."); #region Variables string exportResult = string.Empty; string galleryName = Common.GetConfigurationPropertyValue(Constants.SolutionGalleryName, this.Site); string[] exportFiles = null; string[] expectedFiles = null; #endregion Variables // Initialize the web service with an authenticated account. this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated); // Invoke the ExportSolution operation, a url is expected to be returned and a solution file is expected to be exported. exportResult = this.sitessAdapter.ExportSolution(this.solutionName + Constants.WspExtension, Constants.SolutionTitle, Constants.SolutionDescription, true, true); DateTime beforeLoop = DateTime.Now; TimeSpan waitTime = new TimeSpan(); int repeatTime = 0; int totalRepeatTime = Convert.ToInt32(Common.GetConfigurationPropertyValue(Constants.ExportRepeatTime, this.Site)); string solutions = string.Empty; do { // It is assumed that the server will generate all the exported files and log file after the preconfigured time period. int sleepTime = Convert.ToInt32(Common.GetConfigurationPropertyValue(Constants.ExportWaitTime, this.Site)); Thread.Sleep(1000 * sleepTime); // Get all the file names in the solution library. solutions = this.sutAdapter.GetDocumentLibraryFileNames(string.Empty, string.Empty, galleryName, this.solutionName); exportFiles = solutions == null ? null : solutions.TrimEnd(new char[] { ';' }).Split(';'); // If the expected files are created, the operation is considered as succeed. if (exportFiles != null && exportFiles.Length == 1) { break; } // If the server could not generate all the exported files and log file after the time period ExportWaitTime for some unknown reasons, for example, limit of server resources, try to repeat this sequence again. repeatTime++; }while (repeatTime < totalRepeatTime); waitTime = DateTime.Now - beforeLoop; // If the server still does not generate all the exported files and log file after repeating, or the server generate unexpected number of files, the operation is considered as failed. if (exportFiles == null) { Site.Assert.Fail("The server does not export the files after {0} seconds", waitTime); } else if (exportFiles.Length != 1) { Site.Assert.Fail("The server does not export {0} files as expected but exports {1} file{2} in actual, and the exported file name list is {3}", 1, exportFiles.Length, exportFiles.Length > 1 ? "s" : string.Empty, solutions); } // Format the expected file names in the solution gallery, only one solution file (i.e. SolutionName) is expected. expectedFiles = new string[] { this.solutionName + Constants.WspExtension }; // If returned value is not a url or exported files are inconsistent with the expected, log it. Site.Assert.IsTrue( Uri.IsWellFormedUriString(exportResult, UriKind.Relative), "ExportSolution should return a valid Uri, actual uri {0}.", exportResult); Site.Assert.IsTrue( AdapterHelper.CompareStringArrays(expectedFiles, exportFiles), "ExportSolution should export the solution file."); // If returned value is a url and exported files are consistent with the expected, it means the ExportSolution operation succeed. // Invoke the ExportSolution operation again, a url is expected to be returned and a second solution file is expected to be exported. exportResult = this.sitessAdapter.ExportSolution(this.solutionName + Constants.WspExtension, Constants.SolutionTitle, Constants.SolutionDescription, true, true); beforeLoop = DateTime.Now; waitTime = new TimeSpan(); repeatTime = 0; solutions = string.Empty; do { // It is assumed that the server will generate all the exported files and log file after the preconfigured time period. int sleepTime = Convert.ToInt32(Common.GetConfigurationPropertyValue(Constants.ExportWaitTime, this.Site)); Thread.Sleep(1000 * sleepTime); // Get all the file names in the solution library. solutions = this.sutAdapter.GetDocumentLibraryFileNames(string.Empty, string.Empty, galleryName, this.solutionName); exportFiles = solutions == null ? null : solutions.TrimEnd(new char[] { ';' }).Split(';'); // If the expected files are created, the operation is considered as succeed. if (exportFiles != null && exportFiles.Length == 2) { break; } // If the server could not generate all the exported files and log file after the time period ExportWaitTime for some unknown reasons, for example, limit of server resources, try to repeat this sequence again. repeatTime++; }while (repeatTime < totalRepeatTime); waitTime = DateTime.Now - beforeLoop; // If the server still does not generate all the exported files and log file after repeating, or the server generate unexpected number of files, the operation is considered as failed. if (exportFiles == null) { Site.Assert.Fail("The server does not export the files after {0} seconds", waitTime); } else if (exportFiles.Length != 2) { Site.Assert.Fail("The server does not export {0} files as expected but exports {1} file{2} in actual, and the exported file name list is {3}", 2, exportFiles.Length, exportFiles.Length > 1 ? "s" : string.Empty, solutions); } // Format the expected file names in the solution gallery, two solution files (i.e. SolutionName & SolutionName2) are expected. expectedFiles = new string[] { this.solutionName + Constants.WspExtension, this.solutionName + "2" + Constants.WspExtension }; // If returned value is not a url or exported files are inconsistent with the expected, log it. Site.Assert.IsTrue( Uri.IsWellFormedUriString(exportResult, UriKind.Relative), "ExportSolution should return a valid Uri, actual uri {0}.", exportResult); #region Capture requirements // If exported files are consistent with the expected, it means multiple wsp files // are created and a positive, incrementing integer is append to the second file's // name (i.e. ExportSolution.wsp & ExportSolution2.wsp), so R384 can be captured. bool isMutipleFile = AdapterHelper.CompareStringArrays(expectedFiles, exportFiles); Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R384, the export file is {0}", exportFiles[1]); // Verify MS-SITESS requirement: MS-SITESS_R384 Site.CaptureRequirementIfIsTrue( isMutipleFile, 384, @"[In ExportSolution] [solutionFileName:] If a solution with the specified name already exists in the solution gallery, the server retry with <filename>2.wsp, where <filename> is obtained from solutionFileName after excluding the extension."); // If exported files are consistent with the expected, it means multiple wsp files // are created and a positive, incrementing integer is append to the second file's // name (i.e. ExportSolution.wsp & ExportSolution2.wsp), so R38 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R38, the export file is {0}", exportFiles[1]); // Verify MS-SITESS requirement: MS-SITESS_R38 Site.CaptureRequirementIfIsTrue( isMutipleFile, 38, @"[In ExportSolution] [solutionFileName:] If a unique name is obtained, the server MUST continue with that name [to create a solution file using this unique name]."); // If code can run to here, it means that Microsoft SharePoint Foundation 2010 and above support method ExportSolution. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R5301, Microsoft SharePoint Foundation 2010 and above support method ExportSolution."); // Verify MS-SITESS requirement: MS-SITESS_R5301 Site.CaptureRequirement( 5301, @"[In Appendix B: Product Behavior] Implementation does support this method [ExportSolution]. (Microsoft SharePoint Foundation 2010 and above follow this behavior.)"); #endregion Capture requirements }
public void MSSITESS_S02_TC02_ManagingSubsiteWithoutOptionalParameters() { #region Variables uint localeId = uint.Parse(Common.GetConfigurationPropertyValue(Constants.ValidLCID, this.Site)); Template[] templateList; string webUrl = Common.GetConfigurationPropertyValue(Constants.SiteName, this.Site) + "/" + this.newSubsite; CreateWebResponseCreateWebResult createResult; string expectedUrl = Common.GetConfigurationPropertyValue(Constants.SiteUrl, this.Site) + "/" + this.newSubsite; uint getTemplateResult = 0; string webName = this.newSubsite; uint language = uint.Parse(Common.GetConfigurationPropertyValue(Constants.DefaultLCID, this.Site)); uint locale = uint.Parse(Common.GetConfigurationPropertyValue(Constants.DefaultLCID, this.Site)); #endregion Variables Site.Assume.IsTrue(Common.IsRequirementEnabled(3781, this.Site), @"Test is executed only when R3781Enabled is set to true."); // Initialize the web service with an authenticated account. this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated); // Invoke the GetSiteTemplates operation with valid parameters, so result == 0 and templateList.Length > 1 are expected. getTemplateResult = this.sitessAdapter.GetSiteTemplates(localeId, out templateList); // GetTemplate operation should return more than one template. Site.Assert.IsTrue(templateList.Length > 1, "GetTemplate operation should return more than one template."); #region Capture requirements this.VerifyResultOfGetSiteTemplate(getTemplateResult); #endregion Capture requirements // Invoke the CreateWeb operation without optional parameters, so the return value is expected to contain a url consistent with the expected url. // The first template is a Global template and can't be used to create web ,so templateList[1] is used here. createResult = this.sitessAdapter.CreateWeb(webUrl, Constants.WebTitle, Constants.WebDescription, templateList[1].Name, 0, false, 0, false, 0, false, true, false, true, false, true, false); expectedUrl = expectedUrl.TrimEnd('/'); string actualUrl = createResult.CreateWeb.Url.TrimEnd('/'); // If returned value contain a url consistent with the expected url, it means the CreateWeb operation succeed. Site.Assert.IsTrue( expectedUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase), "Created web's url should be {0}.", expectedUrl); #region Capture requirements // Get a string contains the name and value of the expected properties of the created web. string webPropertyDefault = this.sutAdapter.GetWebProperties(Common.GetConfigurationPropertyValue(Constants.SiteName, this.Site), webName); //// Get each property value by splitting the string. Dictionary <string, string> properties = AdapterHelper.DeserializeWebProperties(webPropertyDefault, Constants.ItemSpliter, Constants.KeySpliter); uint languageActual = uint.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyLanguage, this.Site)]); uint localeActual = uint.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyLocale, this.Site)]); string permissionActual = properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyUserNameInPermissions, this.Site)]; string[] userNameActual = permissionActual.Split(','); bool anonymousActual = bool.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyAnonymous, this.Site)]); // Get a string contains the name and value of the expected properties of the parent web of the created web. string webParentDefault = this.sutAdapter.GetWebProperties(Common.GetConfigurationPropertyValue(Constants.SiteName, this.Site), string.Empty); //// Get each property value by splitting the string. Dictionary <string, string> parentProperties = AdapterHelper.DeserializeWebProperties(webParentDefault, Constants.ItemSpliter, Constants.KeySpliter); string parentPermission = parentProperties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyUserNameInPermissions, this.Site)]; string[] userNameExpected = parentPermission.Split(','); // If language is omitted, R515 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R515"); // Verify MS-SITESS requirement: MS-SITESS_R515 Site.CaptureRequirementIfAreEqual <uint>( language, languageActual, 515, @"[In CreateWeb] [language:] If omitted, the subsite to be created MUST use the server’s default language for the user interface."); // If locale is omitted, R516 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R516"); // Verify MS-SITESS requirement: MS-SITESS_R516 Site.CaptureRequirementIfAreEqual <uint>( locale, localeActual, 516, @"[In CreateWeb] [locale:] If omitted, specifies that the subsite to be created MUST use the server’s default settings for displaying data."); // If uniquePermissions is omitted, R555 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R555, the actual user name is {0}", userNameActual); // Verify MS-SITESS requirement: MS-SITESS_R555 bool isVerifyR555 = AdapterHelper.CompareStringArrays(userNameExpected, userNameActual); Site.CaptureRequirementIfIsTrue( isVerifyR555, 555, @"[In CreateWeb] [uniquePermissions:] If omitted, the subsite to be created MUST inherit its permissions from its parent site."); // If anonymous is omitted, R556 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R556, the actual anonymous is {0}", anonymousActual); // Verify MS-SITESS requirement: MS-SITESS_R556 Site.CaptureRequirementIfIsFalse( anonymousActual, 556, @"[In CreateWeb] [anonymous:] If omitted, the anonymous authentication MUST NOT be allowed for the subsite to be created."); // Verify that Microsoft SharePoint Foundation 2010 and above support operation CreateWeb. this.VerifyOperationCreateWeb(); #endregion Capture requirements // If R3781 is not enabled, that means the CreateWeb operation is not supported, so there is no web to be deleted here. if (Common.IsRequirementEnabled(3781, this.Site) && Common.IsRequirementEnabled(3791, this.Site)) { // Invoke the DeleteWeb operation. this.sitessAdapter.DeleteWeb(webUrl); #region Capture requirements // Verify that Microsoft SharePoint Foundation 2010 and above support operation DeleteWeb. this.VerifyOperationDeleteWeb(); #endregion Capture requirements } }
public void MSSITESS_S05_TC01_ExportWorkflowTemplateSucceed() { Site.Assume.IsTrue(Common.IsRequirementEnabled(5331, this.Site), @"Test is executed only when R5331Enabled is set to true."); #region Variables string templateName = Common.GetConfigurationPropertyValue(Constants.WorkflowTemplateName, this.Site); string destinationUrl = Common.GetConfigurationPropertyValue(Constants.DataPath, this.Site); string exportResult = string.Empty; string[] exportFiles = null; string[] expectedFiles = null; #endregion Variables // Initialize the web service with an authenticated account. this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated); // Invoke ExportWorkflowTemplate operation, a URL is expected to be returned and a solution file is expected to be exported. exportResult = this.sitessAdapter.ExportWorkflowTemplate(this.solutionName + Constants.WspExtension, Constants.SolutionTitle, Constants.SolutionDescription, templateName, destinationUrl); // If returned value is not a URL or exported files are inconsistent with the expected, log it. Site.Assert.IsTrue( Uri.IsWellFormedUriString(exportResult, UriKind.Relative), "ExportWorkflowTemplate should return a valid Uri, actual uri {0}.", exportResult); string solutions = TestSuiteHelper.VerifyExportAndImportFile(this.solutionName, 1, this.Site, this.sutAdapter); exportFiles = solutions == null ? null : solutions.TrimEnd(new char[] { ';' }).Split(';'); this.isSolutionFileCreated = true; // Format the expected file names in the document library, only one solution file (i.e. SolutionName) is expected. expectedFiles = new string[] { this.solutionName + Constants.WspExtension }; Site.Assert.IsTrue( AdapterHelper.CompareStringArrays(expectedFiles, exportFiles), "ExportWorkflowTemplate should export the solution file."); // If returned value is a URL and exported files are consistent with the expected, it means the ExportWorkflowTemplate operation succeed. // Invoke ExportWorkflowTemplate operation again, a URL is expected to be returned and a second solution file is expected to be exported. exportResult = this.sitessAdapter.ExportWorkflowTemplate(this.solutionName + Constants.WspExtension, Constants.SolutionTitle, Constants.SolutionDescription, templateName, destinationUrl); // If returned value is not a URL or exported files are inconsistent with the expected, log it. Site.Assert.IsTrue( Uri.IsWellFormedUriString(exportResult, UriKind.Relative), "ExportWorkflowTemplate should return a valid Uri, actual uri {0}.", exportResult); solutions = TestSuiteHelper.VerifyExportAndImportFile(this.solutionName, 2, this.Site, this.sutAdapter); exportFiles = solutions == null ? null : solutions.TrimEnd(new char[] { ';' }).Split(';'); // Format the expected file names in the document library, two solution files (i.e. SolutionName & SolutionName2) are expected. expectedFiles = new string[] { this.solutionName + Constants.WspExtension, this.solutionName + "2" + Constants.WspExtension }; #region Capture requirements bool isFilesAreEqual = AdapterHelper.CompareStringArrays(expectedFiles, exportFiles); // If the exported files are consistent with the expected, R386 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R386, the export files are {0}", exportFiles); // Verify MS-SITESS requirement: MS-SITESS_R386 Site.CaptureRequirementIfIsTrue( isFilesAreEqual, 386, @"[In ExportWorkflowTemplate] [solutionFileName:] If a solution with the specified name already exists in the document library in which the solution file needs to be created, the server MUST retry with <filename>2.wsp, where <filename> is obtained from solutionFileName after excluding the extension."); // If the exported files are consistent with the expected, R109 can be captured. Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R109, the export files are {0}", exportFiles); // Verify MS-SITESS requirement: MS-SITESS_R109 Site.CaptureRequirementIfIsTrue( isFilesAreEqual, 109, @"[In ExportWorkflowTemplate] [solutionFileName:] If a unique name is obtained, the protocol server MUST continue with that name [to create a solution file using this unique name]."); // If code can run to here, it means that Microsoft SharePoint Foundation 2010 and above support operation ExportWorkflowTemplate. this.VerifyOperationExportWorkflowTemplate(); #endregion Capture requirements }