Exemple #1
0
        /// <summary>
        /// upload a file to the specified document library and record the file URL in order to cleanup the file in test suite clean up process.
        /// </summary>
        /// <param name="documentLibraryTitle">A parameter represents the title of a document library where the file upload</param>
        /// <returns>A return value represents the URL of the uploaded file.</returns>
        protected string UploadFileToSut(string documentLibraryTitle)
        {
            if (string.IsNullOrEmpty(documentLibraryTitle))
            {
                throw new ArgumentException("Should specify valid value to indicate the title of target document library", "documentLibraryTitle");
            }

            string uploadFileUrl = SutController.UploadFileToDocumentLibrary(documentLibraryTitle);

            if (string.IsNullOrEmpty(uploadFileUrl))
            {
                this.Site.Assert.Fail("Upload file to [{0}] list fail.", documentLibraryTitle);
            }

            UploadedFilesUrlRecorder.Add(uploadFileUrl);
            return(uploadFileUrl);
        }
Exemple #2
0
        public void TestSuiteBaseCleanUp()
        {
            bool isCleanUpUploadedFilesSucceed = false;
            bool isCleanUpStartedTasksSucceed  = false;

            string uploadedfilesUrls = string.Empty;

            if (null != UploadedFilesUrlRecorder && UploadedFilesUrlRecorder.Count > 0)
            {
                StringBuilder strBuilder = new StringBuilder();
                foreach (string urlsOfUploadFileItem in UploadedFilesUrlRecorder)
                {
                    strBuilder.Append(urlsOfUploadFileItem + ",");
                }

                // Remove last "," symbol
                uploadedfilesUrls             = strBuilder.ToString(0, strBuilder.Length - 1);
                isCleanUpUploadedFilesSucceed = SutController.CleanUpUploadedFiles(DocLibraryName, uploadedfilesUrls);
                UploadedFilesUrlRecorder.Clear();
            }
            else
            {
                isCleanUpUploadedFilesSucceed = true;
            }

            string taskids = string.Empty;

            if (null != StartedTaskIdsRecorder && StartedTaskIdsRecorder.Count > 0)
            {
                StringBuilder strBuilder = new StringBuilder();
                foreach (string taskIditem in StartedTaskIdsRecorder)
                {
                    strBuilder.Append(taskIditem + ",");
                }

                // Remove last "," symbol
                taskids = strBuilder.ToString(0, strBuilder.Length - 1);
                isCleanUpStartedTasksSucceed = SutController.CleanUpStartedTasks(TaskListName, taskids);
                StartedTaskIdsRecorder.Clear();
            }
            else
            {
                isCleanUpStartedTasksSucceed = true;
            }

            string cleanUpProcessLogs = string.Empty;

            if (!isCleanUpStartedTasksSucceed)
            {
                string taskListName = Common.GetConfigurationPropertyValue("CurrentTaskListName", this.Site);
                cleanUpProcessLogs = string.Format(
                    "There are some failures when cleaning up below tasks in task list[{0}].\r\nTasks ids:\r\n{1}\r\n",
                    taskListName,
                    taskids);
            }

            if (!isCleanUpUploadedFilesSucceed)
            {
                string documentListName = Common.GetConfigurationPropertyValue("CurrentDocLibraryListName", this.Site);
                cleanUpProcessLogs = string.Format(
                    "{0}\r\nThere are some failures when cleaning up below files in Document Library[{1}].\r\nFiles urls:\r\n{2}",
                    cleanUpProcessLogs,
                    documentListName,
                    uploadedfilesUrls);
            }

            if (!string.IsNullOrEmpty(cleanUpProcessLogs))
            {
                this.Site.Assert.Fail(
                    "Clean up errors:\r\n{0}",
                    cleanUpProcessLogs);
            }
        }