Microsoft.Protocols.TestSuites.MS_SITESS.S02_ManageSubSite.MSSITESS_S02_TC02_ManagingSubsiteWithoutOptionalParameters C# (CSharp) Méthode

MSSITESS_S02_TC02_ManagingSubsiteWithoutOptionalParameters() private méthode

        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
            }
        }