public void MSSITESS_S03_TC02_GetUpdatedFormDigestInformation()
        {
            Site.Assume.IsTrue(Common.IsRequirementEnabled(5381, this.Site), @"Test is executed only when R5381Enabled is set to true.");

            string webPageUrl = Common.GetConfigurationPropertyValue(Constants.WebPageUrl, this.Site);
            FormDigestInformation currentInfo = new FormDigestInformation();
            FormDigestInformation newInfo = new FormDigestInformation();
            string urlStr = string.Empty;
            int formDigestTimeout = int.Parse(Common.GetConfigurationPropertyValue(Constants.ExpireTimePeriodBySecond, this.Site));
            string currentSite = Common.GetConfigurationPropertyValue(Constants.SiteCollectionUrl, this.Site);

            // Initialize the web service with an authenticated account.
            this.sitessAdapter.InitializeWebService(UserAuthenticationOption.Authenticated);

            // Invoke the GetUpdatedFormDigestInformation operation.
            currentInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            var formDigestValid = this.sutAdapter.PostWebForm(currentInfo.DigestValue, webPageUrl);
            Site.Assert.IsTrue(formDigestValid.Contains(Constants.PostWebFormResponse), "digest accept");

            // If the DigestValue is the valid security validation token, R500 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R500, the DigestValue is {0}.", currentInfo.DigestValue);

            // Verify MS-SITESS requirement: MS-SITESS_R500
            Site.CaptureRequirement(
                500,
                @"[In FormDigestInformation] DigestValue: Security validation token generated by the protocol server.");

            // This sleep is just to wait for security validation returned by the server to expire and add 10 s for buffer, not wait for the server to complete operation or return response.
            Thread.Sleep((1000 * formDigestTimeout) + 10000);

            var formDigestExpired = this.sutAdapter.PostWebForm(currentInfo.DigestValue, webPageUrl);
            if (Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointFoundation2013 ||
                Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointServer2013 || 
                Common.GetConfigurationPropertyValue(Constants.SutVersion, this.Site) == Constants.SharePointServer2016)
            {
                Site.Assert.IsTrue(formDigestExpired.Contains(Constants.TimeOutInformationForSP2013AndSP2016), "digest expired");
            }
            else
            {
                Site.Assert.IsTrue(formDigestExpired.Contains(Constants.TimeOutInformationForSP2007AndSP2010), "digest expired");
            }

            // If the security validation token do expire after specified timeout seconds, R501 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R501, the TimeoutSeconds is {0}.", currentInfo.TimeoutSeconds);

            // Verify MS-SITESS requirement: MS-SITESS_R501
            Site.CaptureRequirement(
                501,
                @"[In FormDigestInformation] TimeoutSeconds: The time in seconds in which the security validation token will expire after the protocol server generates the security validation token server.");

            // Invoke the GetUpdatedFormDigestInformation operation again, the returned security validation is expected to be different with the last one.
            newInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            var formDigestReNewed = this.sutAdapter.PostWebForm(newInfo.DigestValue, webPageUrl);
            Site.Assert.IsTrue(formDigestReNewed.Contains(Constants.PostWebFormResponse), "New digest accept");

            FormDigestInformation nullInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(null);

            string expectUrl = currentSite.TrimEnd('/');
            string actualUrl = nullInfo.WebFullUrl.TrimEnd('/');
            bool isVerifyR550 = expectUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase);

            #region Capture requirements
            // If the url is the current requested site, R550 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R550, the actual URL is {0}.", actualUrl);

            // Verify MS-SITESS requirement: MS-SITESS_R550
            Site.CaptureRequirementIfIsTrue(
                isVerifyR550,
                550,
                @"[In GetUpdatedFormDigestInformation] [url:] If this element is omitted altogether, the protocol server MUST return the FormDigestInformation of the current requested site (2).");
            #endregion Capture requirements

            FormDigestInformation emptyInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            #region Capture requirements
            expectUrl = currentSite.TrimEnd('/');
            actualUrl = emptyInfo.WebFullUrl.TrimEnd('/');
            bool isVerifyR551 = expectUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase);

            // If the url is the current requested site, R551 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R551, the actual URL is {0}.", actualUrl);

            // Verify MS-SITESS requirement: MS-SITESS_R551
            Site.CaptureRequirementIfIsTrue(
                isVerifyR551,
                551,
                @"[In GetUpdatedFormDigestInformation] [url:] If this element is included as an empty string, the protocol server MUST return the FormDigestInformation of the current requested site (2).");
            #endregion Capture requirements

            urlStr = Common.GetConfigurationPropertyValue(Constants.SiteCollectionUrl, this.Site);
            FormDigestInformation otherInfo = this.sitessAdapter.GetUpdatedFormDigestInformation(urlStr);

            #region Capture requirements
            expectUrl = urlStr.TrimEnd('/');
            actualUrl = otherInfo.WebFullUrl.TrimEnd('/');
            bool isVerifyR405 = expectUrl.Equals(actualUrl, StringComparison.CurrentCultureIgnoreCase);

            // If the url is a requested site, R405 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R405, the actual URL is {0}.", actualUrl);

            // Verify MS-SITESS requirement: MS-SITESS_R405
            Site.CaptureRequirementIfIsTrue(
                isVerifyR405,
                405,
                @"[In GetUpdatedFormDigestInformation] [url:] Otherwise[If this element is neither omitted altogether nor included as an empty string], the protocol server MUST return the FormDigestInformation of the site that contains the page specified by this element.");

            // If code can run to here, it means that Microsoft SharePoint Foundation 2010 and above support method GetUpdatedFormDigestInformation.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R5381, Microsoft SharePoint Foundation 2010 and above support method GetUpdatedFormDigestInformation.");

            // Verify MS-SITESS requirement: MS-SITESS_R5381
            Site.CaptureRequirement(
                5381,
                @"[In Appendix B: Product Behavior] Implementation does support this method [GetUpdatedFormDigestInformation]. (Microsoft SharePoint Foundation 2010 and above follow this behavior.)");
            #endregion Capture requirements
        }
        /// <summary>
        /// Verify GetUpdatedFormDigest related requirements.
        /// </summary>
        /// <param name="getUpdatedFormDigestInfoResult">The result of GetUpdatedFormDigestInformation.</param>
        private void VerifyGetUpdatedFormDigestInformation(FormDigestInformation getUpdatedFormDigestInfoResult)
        {
            Site.Log.Add(LogEntryKind.Comment, "Verify common requirements in GetUpdatedFormDigestInformation operation.");
            this.VerifyCommonReqs();

            // If TimeoutSeconds>0 and DigestValue is not empty, then we can be sure that the server returns the two variables.
            bool isRS215Satisfied = getUpdatedFormDigestInfoResult.TimeoutSeconds > 0
                && !string.IsNullOrEmpty(getUpdatedFormDigestInfoResult.DigestValue);

            // If TimeoutSeconds>0 and DigestValue is not empty, R215 can be verified.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R215, the TimeoutSeconds of getUpdatedFormDigestInfoResult is {0}, the DigestValue of getUpdatedFormDigestInfoResult is {1}", getUpdatedFormDigestInfoResult.TimeoutSeconds, getUpdatedFormDigestInfoResult.DigestValue);

            // Verify MS-SITESS requirement: MS-SITESS_R215
            Site.CaptureRequirementIfIsTrue(
                isRS215Satisfied,
                215,
                @"[In GetUpdatedFormDigestInformation] In this operation [GetUpdatedFormDigestInformation], the protocol server MUST return the security validation token's expiration time in addition to the security validation token.");

            // When code can run to this line, it indicates the soap out message for this operation is received, else the operation will throw exception above.
            // So this operation's description is consistent with server.
            Site.CaptureRequirement(
                216,
                @"[In GetUpdatedFormDigestInformation] [The GetUpdatedFormDigestInformation operation is defined as:] <wsdl:operation name=""GetUpdatedFormDigestInformation"">
              <wsdl:input message=""tns:GetUpdatedFormDigestInformationSoapIn"" />
              <wsdl:output message=""tns:GetUpdatedFormDigestInformationSoapOut"" />
              </wsdl:operation>");

            bool isSchemaRight = SchemaValidation.XmlValidationErrors.Count == 0 && SchemaValidation.XmlValidationWarnings.Count == 0;

            // If we can get the element name of GetUpdatedFormDigestInformationResponse, then we can get the element.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R224");

            // Verify MS-SITESS requirement: MS-SITESS_R224
            Site.CaptureRequirementIfIsTrue(
                isSchemaRight,
                224,
                @"[In GetUpdatedFormDigestInformationSoapOut] The SOAP body contains a GetUpdatedFormDigestInformationResponse element.");

            // If the response contains the element GetUpdatedFormDigestInformationResult,then we can be sure the format of GetUpdatedFormDigestInformationResponse.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-SITESS_R228");

            // Verify MS-SITESS requirement: MS-SITESS_R228
            Site.CaptureRequirementIfIsTrue(
                isSchemaRight,
                228,
                @"[In GetUpdatedFormDigestInformationResponse] [The GetUpdatedFormDigestInformationResponse element is defined as:] <s:element name=""GetUpdatedFormDigestInformationResponse"">
              <s:complexType>
              <s:sequence>
              <s:element minOccurs=""1"" maxOccurs=""1""
              name=""GetUpdatedFormDigestInformationResult""
              type=""tns:FormDigestInformation"" />
              </s:sequence>
              </s:complexType>
              </s:element>");

            // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R218.
            Site.CaptureRequirementIfIsTrue(
                isSchemaRight,
                218,
                @"[In GetUpdatedFormDigestInformation] [The protocol client sends a GetUpdatedFormDigestInformationSoapIn request message and] the protocol server responds with a GetUpdatedFormDigestInformationSoapOut response message.");

            // When the variable isSchemaRight is true, it exposes that the message's format described in the Open Specification is consistent with server. So we can verify R231.
            Site.CaptureRequirementIfIsTrue(
                isSchemaRight,
                231,
                @"[In FormDigestInformation] [The FormDigestInformation complex type is defined as:] <s:complexType name=""FormDigestInformation"">
  <s:sequence>
    <s:element minOccurs=""0"" maxOccurs=""1"" name=""DigestValue"" type=""s:string"" /> 
    <s:element minOccurs=""1"" maxOccurs=""1"" name=""TimeoutSeconds"" type=""s:int"" /> 
    <s:element minOccurs=""0"" maxOccurs=""1"" name=""WebFullUrl"" type=""s:string"" />
    <s:element minOccurs=""0"" maxOccurs=""1"" name=""LibraryVersion"" type=""s:string"" />
    <s:element minOccurs=""0"" maxOccurs=""1"" name=""SupportedSchemaVersions"" type=""s:string"" />
  </s:sequence>
</s:complexType>");

            // If the library version is right, MS-CSOM_R1 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-CSOM_R1, the LibraryVersion of getUpdatedFormDigestInfoResult is {0}", getUpdatedFormDigestInfoResult.LibraryVersion);

            // Verify MS-SITESS requirement: MS-CSOM_R1
            Site.CaptureRequirementIfIsTrue(
                isSchemaRight,
                "MS-CSOM",
                1,
                @"[In VersionStringType] [The VersionStringType is defined as:] <xs:simpleType name=""VersionStringType"" xmlns:xs=""http://www.w3.org/2001/XMLSchema"">
  <xs:restriction base=""xs:string"">
    <xs:pattern value=""[0-9]{1,8}\.[0-9]{1,8}\.[0-9]{1,8}\.[0-9]{1,8}""/>
  </xs:restriction>
</xs:simpleType>");

            // If the SupportedSchemaVersions is comma-separated list of ""14.0.0.0"" or ""15.0.0.0"", MS-CSOM_R2 can be captured.
            Site.Log.Add(LogEntryKind.Debug, "Verify MS-CSOM_R2", getUpdatedFormDigestInfoResult.SupportedSchemaVersions);

            bool isVerifyR2 = true;

            char[] separator = new char[] { ',' };
            string[] splitResult = { };
            splitResult = getUpdatedFormDigestInfoResult.SupportedSchemaVersions.Split(separator);
            for (int i = 0; i < splitResult.Length; i++)
            {
                if (splitResult[i] != "14.0.0.0" && splitResult[i] != "15.0.0.0")
                {
                    isVerifyR2 = false;
                    break;
                }
            }

            // Verify MS-SITESS requirement: MS-CSOM_R2
            Site.CaptureRequirementIfIsTrue(
                isVerifyR2,
                "MS-CSOM",
                2,
                @"[In Attributes] [SchemaVersion:] This value MUST be ""14.0.0.0"" or ""15.0.0.0"".");
        }