public void TestDirectoryCreation() { var rng = new Random(); string basePath = Path.Combine(Path.GetTempPath(), "DataDirTests", "creation"); string testPath; do { testPath = $"{basePath}_{DateTime.Now.Ticks:x}_{rng.Next():x}"; } while (Directory.Exists(testPath)); var dd = new DataDir(testPath); Assert.IsFalse(dd.DirectoryExists); dd.CreateIfNotExists(); Assert.IsTrue(dd.DirectoryExists); Assert.IsTrue(Directory.Exists(testPath)); dd.CreateIfNotExists(); Directory.Delete(testPath); Assert.IsFalse(dd.DirectoryExists); }