System.IO.FileCleanupTestBase.FileCleanupTestBase C# (CSharp) Méthode

FileCleanupTestBase() protected méthode

Initialize the test class base. This creates the associated test directory.
protected FileCleanupTestBase ( ) : System.Runtime.CompilerServices
Résultat System.Runtime.CompilerServices
        protected FileCleanupTestBase()
        {
            // Use a unique test directory per test class.  The test directory lives in the user's temp directory,
            // and includes both the name of the test class and a random string.  The test class name is included 
            // so that it can be easily correlated if necessary, and the random string to helps avoid conflicts if
            // the same test should be run concurrently with itself (e.g. if a [Fact] method lives on a base class) 
            // or if some stray files were left over from a previous run.
            TestDirectory = Path.Combine(Path.GetTempPath(), GetType().Name + "_" + Path.GetRandomFileName());
            try
            {
                Directory.CreateDirectory(TestDirectory);
            }
            catch
            {
                // Don't throw exceptions during test class construction.  Attempts to use paths
                // under this directory will instead appropriately fail later.
            }
        }