Exemple #1
0
        /// <summary>
        /// This method is used to record the status which one file is uploaded to the specified full file URI.
        /// </summary>
        /// <param name="url">Specify the full file URL.</param>
        public void RecordFileUpload(string url)
        {
            Action function = () =>
            {
                IMS_FSSHTTP_FSSHTTPBManagedCodeSUTControlAdapter sutAdapter = this.site.GetAdapter <IMS_FSSHTTP_FSSHTTPBManagedCodeSUTControlAdapter>();
                string fileUrl  = url.Substring(0, url.LastIndexOf("/", StringComparison.OrdinalIgnoreCase));
                string fileName = url.Substring(url.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1);
                try
                {
                    if (!sutAdapter.RemoveFile(fileUrl, fileName))
                    {
                        this.errorMessage.Add(string.Format("Cannot remove a file in the URL {0}", url));
                        this.isEnvironmentRollbackSuccess = false;
                    }
                }
                catch (Microsoft.VisualStudio.TestTools.UnitTesting.AssertInconclusiveException e)
                {
                    // Here try to catch the exception to avoid the removing file failure due to the server cannot release the lock as expected.
                    this.errorMessage.Add(e.Message);
                    this.isEnvironmentRollbackSuccess = false;
                }
            };

            this.AddOrUpdate(url, function, KeyStatus.UploadTextFile);
        }
        /// <summary>
        /// This method is used to record the specified file URL which has been checked out.
        /// </summary>
        /// <param name="fileUrl">Specify the file URL which has been checked out.</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>
        public void RecordFileCheckOut(string fileUrl, string userName, string password, string domain)
        {
            Action function = () =>
            {
                IMS_FSSHTTP_FSSHTTPBManagedCodeSUTControlAdapter sutAdapter = this.site.GetAdapter <IMS_FSSHTTP_FSSHTTPBManagedCodeSUTControlAdapter>();
                if (!sutAdapter.CheckInFile(fileUrl, userName, password, domain, "Check In for test purpose."))
                {
                    this.errorMessage.Add(string.Format("Failed to check in the file {0} using the user {1}/{2} and password: {3}", fileUrl, userName, domain, password));
                    this.isEnvironmentRollbackSuccess = false;
                }
            };

            this.AddOrUpdate(fileUrl, function, KeyStatus.CheckOut);
        }