public void MSFSSHTTP_FSSHTTPB_S02_TC03_CoauthSubRequest_FileAlreadyCheckedOutOnServer()
        {
            // Use SUT method to check out the file.
            if (!this.SutManagedAdapter.CheckOutFile(this.DefaultFileUrl, this.UserName02, this.Password02, this.Domain))
            {
                this.Site.Assert.Fail("Cannot change the file {0} to check out status using the user name {1} and password {2}", this.DefaultFileUrl, this.UserName02, this.Password02);
            }

            this.StatusManager.RecordFileCheckOut(this.DefaultFileUrl, this.UserName02, this.Password02, this.Domain);

            // Initialize the service
            this.InitializeContext(this.DefaultFileUrl, this.UserName01, this.Password01, this.Domain);

            // Join a Coauthoring session, if the coauthorable file is checked out on the server and is checked out by a client with a different user name, the server returns a FileAlreadyCheckedOutOnServer error code.
            // Now the web service is initialized using the user01, so the user is different with the user who check the file out.
            CoauthSubRequestType  subRequest   = SharedTestSuiteHelper.CreateCoauthSubRequestForJoinCoauthSession(SharedTestSuiteHelper.DefaultClientID, SharedTestSuiteHelper.ReservedSchemaLockID);
            CellStorageResponse   cellResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            CoauthSubResponseType joinResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(cellResponse, 0, 0, this.Site);

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1555
                Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                    ErrorCodeType.FileAlreadyCheckedOutOnServer,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(joinResponse.ErrorCode, this.Site),
                    "MS-FSSHTTP",
                    1555,
                    @"[In Join Coauthoring Session]  If the coauthorable file is checked out on the server and checked out by a client with a different user name than the current client, the protocol server returns an error code value set to ""FileAlreadyCheckedOutOnServer"".");
            }
            else
            {
                Site.Assert.AreEqual <ErrorCodeType>(
                    ErrorCodeType.FileAlreadyCheckedOutOnServer,
                    SharedTestSuiteHelper.ConvertToErrorCodeType(joinResponse.ErrorCode, this.Site),
                    @"[When sending Join Coauthoring Session subrequest] If the coauthorable file is checked out on the server and checked out by a client with a different user name than the current client, the protocol server returns an error code value set to ""FileAlreadyCheckedOutOnServer"".");
            }

            bool isVerifyR385 = joinResponse.ErrorMessage != null && joinResponse.ErrorMessage.IndexOf(this.UserName02, StringComparison.OrdinalIgnoreCase) >= 0;

            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    "For the requirement MS-FSSHTTP_R385, the error message should contain the user name {0}, actual value is {1}",
                    this.UserName02,
                    joinResponse.ErrorMessage);

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR385,
                    "MS-FSSHTTP",
                    385,
                    @"[In LockAndCoauthRelatedErrorCodeTypes][FileAlreadyCheckedOutOnServer] When the ""FileAlreadyCheckedOutOnServer"" error code is returned as the error code value in the SubResponse element, the protocol server returns the identity of the user who has currently checked out the file in the error message attribute.");
            }
            else
            {
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    "The error message should contain the user name {0}, actual value is {1}",
                    this.UserName02,
                    joinResponse.ErrorMessage);

                Site.Assert.IsTrue(
                    isVerifyR385,
                    @"When the ""FileAlreadyCheckedOutOnServer"" error code is returned as the error code value in the SubResponse element, the protocol server returns the identity of the user who has currently checked out the file in the error message attribute.");
            }

            // Refresh the Coauthoring Session, if the coauthorable file is checked out on the server and is checked out by a client with a different user name,
            // the server returns a FileAlreadyCheckedOutOnServer error code.
            subRequest   = SharedTestSuiteHelper.CreateCoauthSubRequestForRefreshCoauthoringSession(SharedTestSuiteHelper.DefaultClientID, SharedTestSuiteHelper.ReservedSchemaLockID);
            cellResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            CoauthSubResponseType refreshResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(cellResponse, 0, 0, this.Site);

            isVerifyR385 = refreshResponse.ErrorMessage != null && refreshResponse.ErrorMessage.IndexOf(this.UserName02, StringComparison.OrdinalIgnoreCase) >= 0;
            if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
            {
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 1566, this.Site))
                {
                    // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1566
                    Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                        ErrorCodeType.FileAlreadyCheckedOutOnServer,
                        SharedTestSuiteHelper.ConvertToErrorCodeType(refreshResponse.ErrorCode, this.Site),
                        "MS-FSSHTTP",
                        1566,
                        @"[In Refresh Coauthoring Session][When sending Refresh Coauthoring Session subrequest] If the coauthorable file is checked out on the server and checked out by a client with a different user name than the current client, the protocol server returns an error code value set to ""FileAlreadyCheckedOutOnServer"".");
                }
                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    "For the requirement MS-FSSHTTP_R385, the error message should contain the user name {0}, actual value is {1}",
                    this.UserName02,
                    refreshResponse.ErrorMessage);

                Site.CaptureRequirementIfIsTrue(
                    isVerifyR385,
                    "MS-FSSHTTP",
                    385,
                    @"[In LockAndCoauthRelatedErrorCodeTypes][FileAlreadyCheckedOutOnServer] When the ""FileAlreadyCheckedOutOnServer"" error code is returned as the error code value in the SubResponse element, the protocol server returns the identity of the user who has currently checked out the file in the error message attribute.");
            }
            else
            {
                if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 1566, this.Site))
                {
                    Site.Assert.AreEqual <ErrorCodeType>(
                        ErrorCodeType.FileAlreadyCheckedOutOnServer,
                        SharedTestSuiteHelper.ConvertToErrorCodeType(refreshResponse.ErrorCode, this.Site),
                        @"[When sending Refresh Coauthoring Session subrequest]If the coauthorable file is checked out on the server and checked out by a client with a different user name than the current client, the protocol server returns an error code value set to ""FileAlreadyCheckedOutOnServer"".");
                }

                this.Site.Log.Add(
                    LogEntryKind.Debug,
                    "The error message should contain the user name {0}, actual value is {1}",
                    this.UserName02,
                    refreshResponse.ErrorMessage);

                Site.Assert.IsTrue(
                    isVerifyR385,
                    @"When the ""FileAlreadyCheckedOutOnServer"" error code is returned as the error code value in the SubResponse element, the protocol server returns the identity of the user who has currently checked out the file in the error message attribute.");
            }

            // Check Lock Availability of the Coauthoring Session, if the file is already checked out by a different user,
            // the server returns a FileAlreadyCheckedOutOnServer error code.
            subRequest   = SharedTestSuiteHelper.CreateCoauthSubRequestForCheckLockAvailability(SharedTestSuiteHelper.DefaultClientID, SharedTestSuiteHelper.ReservedSchemaLockID);
            cellResponse = this.Adapter.CellStorageRequest(this.DefaultFileUrl, new SubRequestType[] { subRequest });
            CoauthSubResponseType checkResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(cellResponse, 0, 0, this.Site);

            // Add the log information.
            Site.Log.Add(LogEntryKind.Debug, "The errorCode for Check Lock Availability SubRequest is :{0}", checkResponse.ErrorCode);
            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 1082, this.Site))
            {
                if (SharedContext.Current.IsMsFsshttpRequirementsCaptured)
                {
                    // Verify MS-FSSHTTP requirement: MS-FSSHTTP_R1082
                    Site.CaptureRequirementIfAreEqual <ErrorCodeType>(
                        ErrorCodeType.FileAlreadyCheckedOutOnServer,
                        SharedTestSuiteHelper.ConvertToErrorCodeType(checkResponse.ErrorCode, this.Site),
                        "MS-FSSHTTP",
                        1082,
                        @"[In Check Lock Availability] If the coauthorable file is checked out on the server and it is checked out by a client with a different user name than the current client, the protocol server returns an error code value set to ""FileAlreadyCheckedOutOnServer"".");
                }
                else
                {
                    Site.Assert.AreEqual <ErrorCodeType>(
                        ErrorCodeType.FileAlreadyCheckedOutOnServer,
                        SharedTestSuiteHelper.ConvertToErrorCodeType(checkResponse.ErrorCode, this.Site),
                        @"[When sending check lock availability subrequest]If the coauthorable file is checked out on the server and it is checked out by a client with a different user name than the current client, the protocol server returns an error code value set to ""FileAlreadyCheckedOutOnServer"".");
                }
            }
        }
        /// <summary>
        /// This method is used to test whether the lock with the specified id exist on the file.
        /// </summary>
        /// <param name="file">Specify the file.</param>
        /// <param name="schemaLockId">Specify the schemaLock ID.</param>
        /// <param name="userName">Specify the user name of the user who calls cell storage service.</param>
        /// <param name="password">Specify the password of the user who calls cell storage service.</param>
        /// <param name="domain">Specify the domain of the user who calls cell storage service.</param>
        /// <returns>Return true if exist, otherwise return false.</returns>
        protected bool CheckSchemaLockExist(string file, string schemaLockId, string userName, string password, string domain)
        {
            this.InitializeContext(file, userName, password, domain);

            // Generate a new schema lock id value which is different with the given one.
            System.Guid newId;
            do
            {
                newId = System.Guid.NewGuid();
            }while (newId == new System.Guid(schemaLockId));

            if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 93101, this.Site))
            {
                // Check the schema lock availability using the new schema lock id.
                SchemaLockSubRequestType subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.CheckLockAvailability, null, null);
                subRequest.SubRequestData.SchemaLockID = newId.ToString();
                CellStorageResponse       response = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                SchemaLockSubResponseType schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

                ErrorCodeType error = SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site);
                if (error == ErrorCodeType.FileAlreadyLockedOnServer)
                {
                    // Now there could be kind of two conditions:
                    //  1) There is an exclusive lock
                    //  2) There is a schema lock
                    // So it is needed to check the schema lock with the given schema lock id should exist.
                    subRequest = SharedTestSuiteHelper.CreateSchemaLockSubRequest(SchemaLockRequestTypes.CheckLockAvailability, null, null);
                    subRequest.SubRequestData.SchemaLockID = schemaLockId;
                    response = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                    schemaLockSubResponse = SharedTestSuiteHelper.ExtractSubResponse <SchemaLockSubResponseType>(response, 0, 0, this.Site);

                    return(SharedTestSuiteHelper.ConvertToErrorCodeType(schemaLockSubResponse.ErrorCode, this.Site) == ErrorCodeType.Success);
                }
                else
                {
                    if (error != ErrorCodeType.Success)
                    {
                        this.Site.Assert.Fail(
                            "If the schema lock {0} does not exist, check the schema lock using the id {0} should success, but actual the result is {2}",
                            schemaLockId,
                            newId.ToString(),
                            error.ToString());
                    }

                    return(false);
                }
            }
            else if (Common.IsRequirementEnabled("MS-FSSHTTP-FSSHTTPB", 93102, this.Site))
            {
                // Check the schema lock availability using the new schema lock id.
                CoauthSubRequestType  subRequest        = SharedTestSuiteHelper.CreateCoauthSubRequestForCheckLockAvailability(SharedTestSuiteHelper.DefaultClientID, newId.ToString());
                CellStorageResponse   response          = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                CoauthSubResponseType coauthSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(response, 0, 0, this.Site);

                ErrorCodeType error = SharedTestSuiteHelper.ConvertToErrorCodeType(coauthSubResponse.ErrorCode, this.Site);
                if (error == ErrorCodeType.FileAlreadyLockedOnServer)
                {
                    // Now there could be kind of two conditions:
                    //  1) There is an exclusive lock
                    //  2) There is a schema lock
                    // So it is needed to check the schema lock with the given schema lock id should exist.
                    subRequest        = SharedTestSuiteHelper.CreateCoauthSubRequestForCheckLockAvailability(SharedTestSuiteHelper.DefaultClientID, schemaLockId);
                    response          = this.Adapter.CellStorageRequest(file, new SubRequestType[] { subRequest });
                    coauthSubResponse = SharedTestSuiteHelper.ExtractSubResponse <CoauthSubResponseType>(response, 0, 0, this.Site);

                    return(SharedTestSuiteHelper.ConvertToErrorCodeType(coauthSubResponse.ErrorCode, this.Site) == ErrorCodeType.Success);
                }
                else
                {
                    if (error != ErrorCodeType.Success)
                    {
                        this.Site.Assert.Fail(
                            "If the schema lock {0} does not exist, check the schema lock using the id {0} should success, but actual the result is {2}",
                            schemaLockId,
                            newId.ToString(),
                            error.ToString());
                    }

                    return(false);
                }
            }

            this.Site.Assert.Fail("The server should at least support one of operations: Coauthoring session and Schema Lock");
            return(false);
        }