DeserializeWebProperties() public static method

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.
return string>.Dictionary
        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_S02_TC01_ManagingSubsiteSuccessfully()
        {
            #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;

            #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);

            // If the templateList is not empty, it means the GetSiteTemplates operation is succeed.
            Site.Assert.IsTrue(
                templateList != null && templateList.Length > 1,
                "GetTemplate operation should return more than one template.");

            #region Capture requirements

            this.VerifyResultOfGetSiteTemplate(getTemplateResult);

            #endregion Capture requirements

            // Invoke the CreateWeb operation with valid 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, localeId, true, localeId, true, localeId, true, true, true, true, true, true, true);
            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}, but the actual value is {1}.",
                expectedUrl,
                actualUrl);

            #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);
            string permissionActual = properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyUserNameInPermissions, this.Site)];
            string currentUser      = properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyCurrentUser, this.Site)];
            bool   anonymousActual  = bool.Parse(properties[Common.GetConfigurationPropertyValue(Constants.SubSitePropertyAnonymous, this.Site)]);

            // If uniquePermissions is true, R518 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R518, the default user is {0}", currentUser);

            // Verify MS-SITESS requirement: MS-SITESS_R518
            bool isVerifyR518 = false;
            if (permissionActual.Equals(currentUser, StringComparison.CurrentCultureIgnoreCase))
            {
                isVerifyR518 = true;
            }
            else
            {
                string uniqueUserName  = permissionActual;
                string currentUserName = currentUser;
                if (permissionActual.Contains("\\"))
                {
                    int index = permissionActual.IndexOf('\\');
                    uniqueUserName = permissionActual.Substring(index + 1, permissionActual.Length - index - 1);
                }

                if (currentUser.Contains("\\"))
                {
                    int index = currentUser.IndexOf('\\');
                    currentUserName = currentUser.Substring(index + 1, currentUser.Length - index - 1);
                }

                if (uniqueUserName.Equals(currentUserName, StringComparison.CurrentCultureIgnoreCase))
                {
                    isVerifyR518 = true;
                }
            }

            Site.CaptureRequirementIfIsTrue(
                isVerifyR518,
                518,
                @"[In CreateWeb] uniquePermissions: If set to true, specifies that the subsite to be created uses its own set of permissions, which default to the current user having full control and no other users having access");

            // If anonymous is true, R520 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R520, the anonymousActual is {0}", anonymousActual);

            // Verify MS-SITESS requirement: MS-SITESS_R520
            Site.CaptureRequirementIfIsTrue(
                anonymousActual,
                520,
                @"[In CreateWeb] anonymous: If set to true, the anonymous authentication is to 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_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
            }
        }