Microsoft.Protocols.TestSuites.MS_LISTSWS.S05_OperationOnFiles.MSLISTSWS_S05_TC03_CheckInFile_InvalidParameter C# (CSharp) Method

MSLISTSWS_S05_TC03_CheckInFile_InvalidParameter() private method

private MSLISTSWS_S05_TC03_CheckInFile_InvalidParameter ( ) : void
return void
        public void MSLISTSWS_S05_TC03_CheckInFile_InvalidParameter()
        {
            // create a normal document Library and upload a file to SUT
            string listTitle = TestSuiteHelper.GetUniqueListName();
            int docLibraryTemplateId = (int)TemplateType.Document_Library;
            TestSuiteHelper.CreateList(listTitle, docLibraryTemplateId);

            // Upload the file to the document library
            string absoluteFileUrl = this.sutControlAdapter.UploadFile(listTitle);
            Site.Assert.IsTrue(
                        !string.IsNullOrEmpty(absoluteFileUrl),
                        "Upload file to the list {0} should be successful, the file path is [{1}]",
                        listTitle,
                        absoluteFileUrl);

            #region Check out the added file.

            bool isFileCheckOutSuccessfully = false;
            isFileCheckOutSuccessfully = this.listwsInstance.CheckOutFile(absoluteFileUrl, bool.TrueString, string.Empty);

            Site.Assert.IsTrue(isFileCheckOutSuccessfully, "CheckOutFile must succeed!");

            #endregion

            #region Try to check in the file which has been checked out with invalid pageUrl parameter.

            bool isSoapFaultExisted = false;
            string errorCode = string.Empty;
            try
            {
                string nullPageUrl = null;
                this.listwsInstance.CheckInFile(nullPageUrl, string.Empty, CheckInTypeValue.MajorCheckIn);
            }
            catch (SoapException soapEx)
            {
                isSoapFaultExisted = true;
                errorCode = TestSuiteHelper.GetErrorCode(soapEx);
            }

            #endregion

            #region Capture R390 if the error code 0x82000001 is returned.

            // if there are a soap fault and the error code equal to the "0x82000001", capture R390
            Site.CaptureRequirementIfIsTrue(
                                isSoapFaultExisted && errorCode.Equals("0x82000001", StringComparison.OrdinalIgnoreCase),
                                390,
                                @"[In CheckInFile operation] If the pageUrl is null the protocol server MUST return a SOAP fault with error code 0x82000001.");
            #endregion

            #region Try to check in the file if the pageUrl is empty string.

            isSoapFaultExisted = false;
            errorCode = string.Empty;
            try
            {
                string emptyPageUrl = string.Empty;
                this.listwsInstance.CheckInFile(emptyPageUrl, string.Empty, CheckInTypeValue.MajorCheckIn);
            }
            catch (SoapException soapEx)
            {
                isSoapFaultExisted = true;
                errorCode = TestSuiteHelper.GetErrorCode(soapEx);
            }

            // if there are a soap fault and the error code equal to the "0x82000001", capture R391
            Site.CaptureRequirementIfIsTrue(
                                    isSoapFaultExisted && errorCode.Equals("0x82000001", StringComparison.OrdinalIgnoreCase),
                                    391,
                                    @"[In CheckInFile operation] If the pageUrl is empty string the protocol server MUST return a SOAP fault with error code 0x82000001.");

            // if there are a soap fault and the error code equal to the "0x82000001", capture 1640 
            Site.CaptureRequirementIfIsTrue(
                                 isSoapFaultExisted && errorCode.Equals("0x82000001", StringComparison.OrdinalIgnoreCase),
                                1640,
                                @"[In CheckInFile operation] [If the pageUrl is empty string the protocol server MUST return a SOAP fault with error code 0x82000001.] This indicates that the parameter pageUrl is missing.");

            #endregion

            #region Try to check in the file if pageUrl setting to an invalid URL.

            isSoapFaultExisted = false;
            string errorString = string.Empty;
            errorCode = string.Empty;
            try
            {
                string invalidPageUrl = "/";
                this.listwsInstance.CheckInFile(invalidPageUrl, string.Empty, CheckInTypeValue.MajorCheckIn);
            }
            catch (SoapException soapEx)
            {
                isSoapFaultExisted = true;
                errorString = TestSuiteHelper.GetErrorString(soapEx);
            }

            if (Common.IsRequirementEnabled(3921, this.Site))
            {
                // Add the debug information
                this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-LISTSWS_R3921. SOAP fault {0}.", isSoapFaultExisted ? "is returned with error string '" + errorString + "'" : "is not returned");

                // Verify MS-LISTSWS requirement: MS-LISTSWS_R3921
                bool isVerifiedR3921 = isSoapFaultExisted && string.Equals(errorString, "Invalid URI: The format of the URI could not be determined.");

                this.Site.CaptureRequirementIfIsTrue(
                    isVerifiedR3921,
                    3921,
                    @"[In CheckInFile operation] [If the pageUrl is an invalid URL] Implementation does return a SOAP fault with error string ""Invalid URI: The format of the URI could not be determined"".(SharePoint Foundation 2010 and above follow this behavior.)");

                // Verify MS-LISTSWS requirement: MS-LISTSWS_R1641
                this.Site.CaptureRequirementIfIsTrue(
                                         isVerifiedR3921,
                                         1641,
                                         @"[In CheckInFile operation] [If the pageUrl is an invalid URL, the protocol server SHOULD<32> return a SOAP fault with error string ""Invalid URI: The format of the URI could not be determined"".] This indicates that the parameter pageUrl is invalid.");
            }

            if (Common.IsRequirementEnabled(3922, this.Site))
            {
                this.Site.CaptureRequirementIfIsFalse(
                    isSoapFaultExisted,
                    3922,
                    @"[In CheckInFile operation] [If the pageUrl is an invalid URL] Implementation does not return a SOAP fault.(<32> Section 3.1.4.7:  Windows SharePoint Services 3.0 does not return a SOAP fault..)");
            }

            #endregion

            #region Try to check in the file that have been check in success

            bool isCheckInSuccess = false;

            // Call the "CheckInFile" operation and ensure check in successfully.  
            isCheckInSuccess = this.listwsInstance.CheckInFile(absoluteFileUrl, string.Empty, CheckInTypeValue.MajorCheckIn);
            Site.Assert.IsTrue(isCheckInSuccess, "CheckInFile operation must be successfully for the first time");

            // Call the "CheckInFile" operation to check in the file which have been check in successfully in previous checked in file operation.
            isCheckInSuccess = this.listwsInstance.CheckInFile(absoluteFileUrl, string.Empty, CheckInTypeValue.MajorCheckIn);

            // If "CheckInFile" operation return false, capture R2304
            Site.CaptureRequirementIfIsFalse(
                isCheckInSuccess,
                2304,
                @"[CheckInFileResponse][CheckInFileResult] [The value is True if the operation is successful;] otherwise, False is returned.");

            #endregion
        }