Пример #1
0
        public static AutoLoader PrepareLoader(Type type)
        {
            if (!_files.ContainsKey(type))
            {
                throw new Exception("Project Not Found");
            }

            var file = _files[type];

            // copy to test automation directory
            string filePath = getAbsolutePath(file.RelativePath, Directory.GetCurrentDirectory());

            DirectoryHelpers.DirectoryCopy(filePath, TEMP_DIR);

            return(file);
        }
Пример #2
0
        /// <summary>
        /// Files may be locked by OS for a while after process have been killed.
        /// This causes the test to fail, because files can't be deleted.
        /// Tests shows that 10 seconds are enough for files to be released.
        /// Instead of Thread.Sleep(10 seconds), 5 trials are done with 2 seconds between every trial
        /// </summary>
        private static void DeleteTempDirectory()
        {
            int trials = 0;

            while (trials < TRIALS_TO_DELETE_LOCKED_FILES)
            {
                try
                {
                    if (Directory.Exists(AutoLoader.TEMP_DIR))
                    {
                        DirectoryHelpers.DeleteDirectoryContents(AutoLoader.TEMP_DIR);
                    }

                    break;
                }
                catch
                {
                    System.Threading.Thread.Sleep(2000);
                    trials++;
                }
            }
        }