Microsoft.Protocols.TestSuites.MS_VERSS.S03_ErrorConditions.MSVERSS_S03_TC01_FileNotFound C# (CSharp) Method

MSVERSS_S03_TC01_FileNotFound() private method

private MSVERSS_S03_TC01_FileNotFound ( ) : void
return void
        public void MSVERSS_S03_TC01_FileNotFound()
        {
            // The variable is used to save the soap error code returned from server.
            string errorCode = string.Empty;

            // The variable is used to save the soap error string returned from server.
            string errorString = string.Empty;

            string nonExistentFileName = Common.GetConfigurationPropertyValue("NonExistentFileName", this.Site);

            // The variable is used to save the relative path of the non-exist file name in the document library.
            string fileUrl = this.documentLibrary + "/" + nonExistentFileName;

            // This variable is used to save the version of the non-exist file to be deleted.
            string fileVersionOfNonExist = "1.0";

            // Verify the requirements related with DeleteAllVersions operation.
            if (Common.IsRequirementEnabled(9301, this.Site) || Common.IsRequirementEnabled(9302, this.Site) || Common.IsRequirementEnabled(9303, this.Site))
            {
                try
                {
                    // Call DeleteAllVersion operation to delete the specified file that cannot find.
                    this.protocolAdapterInstance.DeleteAllVersions(fileUrl);
                    Site.Assert.Fail(
                        "The deleteAllVersion operation should fail. The specified file cannot be find.");
                }
                catch (SoapException ex)
                {
                    // The error is generated by the file specified by the fileName element of the DeleteAllVersions element
                    // could not be found on the site. 
                    // Verify the SOAPFaultDetails complex type related requirements in adapter.
                    errorCode = Common.ExtractErrorCodeFromSoapFault(ex);
                    errorString = AdapterHelper.ExtractErrorStringFromSoapFault(ex);
                    Site.Log.Add(LogEntryKind.Debug, "The errorCode is {0}, the errorstring is {1}", errorCode, errorString);

                    if (Common.IsRequirementEnabled(9301, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R9301");

                        // Verify MS-VERSS requirement: MS-VERSS_R9301
                        Site.CaptureRequirementIfAreEqual<string>(
                            "0x81070906",
                            errorCode,
                            9301,
                            @"[In Appendix B: Product Behavior] Implementation does return error code 0x81070906. (<2> Section 3.1.4.1.2.2: Windows SharePoint Services 3.0 returns the 0x81070906 error code.)");
                    }

                    if (Common.IsRequirementEnabled(9302, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R9302");

                        // Verify MS-VERSS requirement: MS-VERSS_R9302
                        Site.CaptureRequirementIfIsNull(
                            errorCode,
                            9302,
                            @"[In Appendix B: Product Behavior] Implementation does not return error code. (<2> Section 3.1.4.1.2.2: SharePoint Foundation 2010 returns no error code.)");
                    }

                    if (Common.IsRequirementEnabled(9303, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R9303");

                        Site.CaptureRequirementIfIsNull(
                            errorCode,
                            9303,
                            @"[In Appendix B: Product Behavior] Implementation does not return error code indicate that the system cannot find the specified file. Exception from HRESULT: 0x80070002. (Microsoft SharePoint Foundation 2013.)");
                    }
                }
            }

            // Verify the requirements related with DeleteVersion Operation.
            try
            {
                // Call DeleteVersion operation to delete the non-exist file.
                this.protocolAdapterInstance.DeleteVersion(fileUrl, fileVersionOfNonExist);
                Site.Assert.Fail(
                    "The DeleteVersion operation should fail since the file does not exist. The file URL is {0}",
                    fileUrl);
            }
            catch (SoapException ex)
            {
                // The error is generated when the file does not exist. Verify the SOAPFaultDetails complex type
                // related requirements in adapter.
                errorCode = Common.ExtractErrorCodeFromSoapFault(ex);
                errorString = AdapterHelper.ExtractErrorStringFromSoapFault(ex);

                string sutVersion = Common.GetConfigurationPropertyValue("SutVersion", this.Site);
                if (Common.IsRequirementEnabled(17802021, this.Site))
                {
                   // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R178");

                    // Verify MS-VERSS requirement: MS-VERSS_R178
                    Site.CaptureRequirementIfAreEqual<string>(
                        "0x80131600",
                        errorCode,
                        178,
                        @"[In DeleteVersionResponse] If the specified version does not exist, error code 0x80131600 is returned. ");

                    // Add the debug information
                    Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R17802021");

                    // Verify MS-VERSS requirement: MS-VERSS_R17802021
                    Site.CaptureRequirementIfAreEqual<string>(
                        "0x80131600",
                        errorCode,
                        17802021,
                        @"[In Appendix B: Product Behavior] Implementation does return error code 0x80131600, when the file does not exist. (SharePoint Foundation 2010 and above follow this behavior.)");
                }
            }

            // Verify the requirements related with GetVersion operation.
            try
            {
                // Call GetVersions operation with the non-exist file name.
                this.protocolAdapterInstance.GetVersions(fileUrl);
                Site.Assert.Fail(
                    "The GetVersions operation should fail since the file does not exist. The file URL is {0}",
                    fileUrl);
            }
            catch (SoapException ex)
            {
                errorCode = Common.ExtractErrorCodeFromSoapFault(ex);

                // Add the debug information
                Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R181");

                // Verify MS-VERSS requirement: MS-VERSS_R181
                Site.CaptureRequirementIfIsNull(
                    errorCode,
                    181,
                    @"[In GetVersionsResponse] If the system cannot find the specified file, no error code will be return. ");
            }

            // Verify the requirements related with RestoreVersion Operation.
            if (Common.IsRequirementEnabled(15301, this.Site) || Common.IsRequirementEnabled(204, this.Site))
            {
                try
                {
                    // Call RestoreVersion operation to restore an non-exist file with right format version.
                    this.protocolAdapterInstance.RestoreVersion(fileUrl, fileVersionOfNonExist);
                    Site.Assert.Fail(
                        "The RestoreVersion operation should fail since the file does not exist. The file URL is {0}",
                        fileUrl);
                }
                catch (SoapException ex)
                {
                    // The error is generated if no file with the URL specified by the fileName element of
                    // the RestoreVersion element exist on this site.
                    // Verify the SOAPFaultDetails complex type related requirements in adapter.
                    errorCode = Common.ExtractErrorCodeFromSoapFault(ex);
                    errorString = AdapterHelper.ExtractErrorStringFromSoapFault(ex);
                    Site.Log.Add(LogEntryKind.Debug, "The errorCode is {0}, the errorstring is {1}", errorCode, errorString);

                    if (Common.IsRequirementEnabled(15301, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R15302");

                        // Verify MS-VERSS requirement: MS-VERSS_R15302
                        Site.CaptureRequirementIfIsNull(
                            errorCode,
                            15302,
                            @"[In Appendix B: Product Behavior] Implementation does not return error code to indicate that the file specified by the fileName elements of the RestoreVersion element could not be found on the site. (SharePoint Foundation 2010 and above follow this behavior.)");
                    }

                    if (Common.IsRequirementEnabled(204, this.Site))
                    {
                        // Add the debug information
                        Site.Log.Add(LogEntryKind.Debug, "Verify MS-VERSS_R20401");

                        string expectedErrorString = string.Format("There is no file with URL '{0}' in this Web.", fileUrl);

                        Site.Assert.AreEqual<string>(expectedErrorString, errorString, "The errorstring is {0}.", errorString);

                        // Verify MS-VERSS requirement: MS-VERSS_R20401
                        Site.CaptureRequirementIfAreEqual<string>(
                           "0x81070906",
                           errorCode,
                           20401,
                           @"[In Appendix B: Product Behavior] Implementation does return error code 0x81070906 with the description ""There is no file with URL fileName in this Web."" to indicate that the file specified by the fileName elements of the RestoreVersion element could not be found on the site. (<8> Section 3.1.4.4.2.2:  Windows SharePoint Services 3.0 returns error code 0x81070906 with the description, ""There is no file with URL fileName in this Web."")");
                    }
                }
            }
        }