mirror of
https://github.com/oliverbooth/X10D
synced 2024-11-23 00:18:47 +00:00
fix(test): fix Clear unit test not creating the temp directory
This commit is contained in:
parent
35113fac27
commit
b2a27cdafb
@ -9,34 +9,29 @@ public class DirectoryInfoTests
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void Clear_ShouldClear_GivenValidDirectory()
|
public void Clear_ShouldClear_GivenValidDirectory()
|
||||||
{
|
{
|
||||||
string tempPath = Path.GetTempPath();
|
string tempDirectoryPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||||
DirectoryInfo directory;
|
var tempDirectory = new DirectoryInfo(tempDirectoryPath);
|
||||||
do
|
|
||||||
{
|
|
||||||
string tempDirectory = Path.Combine(tempPath, Guid.NewGuid().ToString());
|
|
||||||
directory = new DirectoryInfo(tempDirectory);
|
|
||||||
} while (directory.Exists);
|
|
||||||
|
|
||||||
directory.Create();
|
tempDirectory.Create();
|
||||||
Assert.IsTrue(directory.Exists);
|
Assert.IsTrue(tempDirectory.Exists);
|
||||||
|
|
||||||
var file = new FileInfo(Path.Combine(directory.FullName, "file"));
|
var file = new FileInfo(Path.Combine(tempDirectory.FullName, "file"));
|
||||||
file.Create().Close();
|
file.Create().Close();
|
||||||
|
|
||||||
var childDirectory = new DirectoryInfo(Path.Combine(directory.FullName, "child"));
|
var childDirectory = new DirectoryInfo(Path.Combine(tempDirectory.FullName, "child"));
|
||||||
childDirectory.Create();
|
childDirectory.Create();
|
||||||
|
|
||||||
var childFile = new FileInfo(Path.Combine(childDirectory.FullName, "childFile"));
|
var childFile = new FileInfo(Path.Combine(childDirectory.FullName, "childFile"));
|
||||||
childFile.Create().Close();
|
childFile.Create().Close();
|
||||||
|
|
||||||
Assert.AreEqual(1, directory.GetFiles().Length);
|
Assert.AreEqual(1, tempDirectory.GetFiles().Length);
|
||||||
Assert.AreEqual(1, directory.GetDirectories().Length);
|
Assert.AreEqual(1, tempDirectory.GetDirectories().Length);
|
||||||
directory.Clear();
|
tempDirectory.Clear();
|
||||||
Assert.AreEqual(0, directory.GetFiles().Length);
|
Assert.AreEqual(0, tempDirectory.GetFiles().Length);
|
||||||
Assert.AreEqual(0, directory.GetDirectories().Length);
|
Assert.AreEqual(0, tempDirectory.GetDirectories().Length);
|
||||||
Assert.IsTrue(directory.Exists);
|
Assert.IsTrue(tempDirectory.Exists);
|
||||||
|
|
||||||
directory.Delete();
|
tempDirectory.Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
Loading…
Reference in New Issue
Block a user