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

DeserializeWebProperties() public static méthode

Deserialize web properties returned by the GetWebProperties method.
public static DeserializeWebProperties ( string prop, char itemSpliter, char keySpliter ) : string>.Dictionary
prop string Web properties string value.
itemSpliter char The char value for item split.
keySpliter char The char value for key and value split.
Résultat string>.Dictionary
        public static Dictionary<string, string> DeserializeWebProperties(string prop, char itemSpliter, char keySpliter)
        {
            string propStr = prop.Trim(itemSpliter);
            string[] array = propStr.Split(itemSpliter);
            Dictionary<string, string> result = new Dictionary<string, string>();
            foreach (string str in array)
            {
                string keyStr = str.Trim(keySpliter);
                string[] temp = keyStr.Split(keySpliter);
                if (temp.Length != 2)
                {
                    testsite.Assert.Fail("DeserializeWebProperties error!", null);
                }

                result.Add(temp[0], temp[1]);
            }

            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::DeserializeWebProperties