Microsoft.Protocols.TestSuites.MS_SITESS.AdapterHelper.CompareStringArrays C# (CSharp) Méthode

CompareStringArrays() public static méthode

Compare two string array's elements.
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.
Résultat bool
        public static bool CompareStringArrays(string[] str1, string[] str2)
        {
            bool result = false;
            int count = 0;

            // Sort the string array to be compared since the order of each element in it is not cared.
            Array.Sort(str1);
            Array.Sort(str2);

            if (str1.Length != str2.Length)
            {
                return result;
            }

            for (; count < str1.Length; count++)
            {
                if (str1[count].Equals(str2[count++]))
                {
                    continue;
                }
                else
                {
                    return result;
                }
            }

            result = true;
            return result;
        }

Usage Example

        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
            }
        }
All Usage Examples Of Microsoft.Protocols.TestSuites.MS_SITESS.AdapterHelper::CompareStringArrays