public void CopyFile_FromFileIsDirectoryThrowsArgumentException() { // Arrange var fs = new MockFileSystem(); fs.CreateDirectory("c:\\old"); const string oldFilePath = "c:\\old"; //long oldSize = 100; const string newFilePath = "c:\\new\\file2.txt"; //long newSize = 300; // Act fs.CopyFile(oldFilePath, newFilePath); // Assert Assert.Fail(); }
public void CopyFileLeavesOldFile() { // Arrange var fs = new MockFileSystem(); const string oldFilePath = "c:\\old\\file1.txt"; const long oldSize = 100; const string newFilePath = "c:\\new\\file2.txt"; fs.AddFile(oldFilePath, oldSize); fs.CreateDirectory("c:\\new"); // Act fs.CopyFile(oldFilePath, newFilePath); // Assert Assert.IsTrue(fs.FileExists(oldFilePath)); Assert.AreEqual(oldSize, fs.GetFileLength(oldFilePath)); }
public void FileDelete_OnDirectoryThrowsUnauthorizedAccessException() { // Arrange var fs = new MockFileSystem(); const string fileName = "c:\\test\\"; fs.CreateDirectory(fileName); // Act fs.DeleteFile(fileName); // Assert Assert.Fail(); }
public void DirectoryExistsReturnsTrueForExistingDirectoryWithTrailingSlash() { // Arrange var fs = new MockFileSystem(); const string newdir = "newdir"; fs.CreateDirectory(newdir); // Act bool result = fs.DirectoryExists(newdir + "\\"); // Assert Assert.IsTrue(result); }
public void DirectoryExistsReturnsTrueForExistingDirectory() { // Arrange var fs = new MockFileSystem(); const string newdir = "newdir"; fs.CreateDirectory(newdir); // Act // Assert Assert.IsTrue(fs.DirectoryExists(newdir)); }
public void DirectoryExistsIsCaseInsensitive() { // Arrange var fs = new MockFileSystem(); fs.CreateDirectory("test\\test2"); // Act // Assert Assert.IsTrue(fs.DirectoryExists("C:\\TEST\\test2")); }
public void DeleteDirectory_RemovesEmptyDirectory() { // Arrange var fs = new MockFileSystem(); const string dirName = "c:\\test"; fs.CreateDirectory(dirName); // Act fs.DeleteDirectory(dirName); // Assert Assert.IsFalse(fs.DirectoryExists(dirName)); }
public void CreateSimpleDirectoryAfterInstantiate() { // Arrange var fs = new MockFileSystem(); const string newdir = "newdir"; // Act fs.CreateDirectory(newdir); // Assert Assert.IsTrue(fs.DirectoryExists(newdir)); }
public void DeleteDirectory_RemoveNonEmptyDirectoryThrowsIoException() { // Arrange var fs = new MockFileSystem(); string dirName = "c:\\test"; fs.CreateDirectory(dirName); fs.AddFile(dirName + "\\file1.txt", 100); // Act fs.DeleteDirectory(dirName); // Assert Assert.Fail(); }
public void CreateNestedDirectoryFromCurrentWithTrailingSlash() { // Arrange var fs = new MockFileSystem(); // Act fs.CreateDirectory("test\\test2\\"); // Assert Assert.IsTrue(fs.DirectoryExists("c:\\test\\test2")); }
public void CreateExistingDirectoryThrowsIoException() { // Arrange var fs = new MockFileSystem(); fs.CreateDirectory("test"); // Act fs.CreateDirectory("test"); // Assert Assert.Fail(); }
public void CreateDirectoryFromCurrent() { // Arrange var fs = new MockFileSystem(); // Act fs.CreateDirectory("test"); // Assert Assert.IsTrue(fs.DirectoryExists("c:\\test")); }
public void CreateAbsoluteDirectoryFromExistingDriveWithTrailingSlash() { // Arrange var fs = new MockFileSystem(); // Act fs.CreateDirectory("c:\\test\\"); // Assert Assert.IsTrue(fs.DirectoryExists("c:\\test")); }
public void CopyFile_ToFileIsNullThrowsArgumentNullException() { // Arrange var fs = new MockFileSystem(); fs.CreateDirectory("c:\\new"); const string oldFilePath = "c:\\old\\file1.txt"; const long oldSize = 100; fs.AddFile(oldFilePath, oldSize); // Act fs.CopyFile(oldFilePath, null); // Assert Assert.Fail(); }