public void CopyFileToExistingFileThrowsIoException() { // Arrange var fs = new MockFileSystem(); const string oldFilePath = "c:\\old\\file1.txt"; const long oldSize = 100; const string newFilePath = "c:\\new\\file2.txt"; const long newSize = 300; fs.AddFile(oldFilePath, oldSize); fs.AddFile(newFilePath, newSize); // 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 GetFileSizeReturnsCorrectValue() { // Arrange var fs = new MockFileSystem(); const int size = 352; const string file = "c:\\testFile.txt"; fs.AddFile(file, size); // Act long value = fs.GetFileLength(file); // Assert Assert.AreEqual(size, value); }
public void FileDelete_RemovesFile() { // Arrange var fs = new MockFileSystem(); const string fileName = "c:\\test\\file1.txt"; fs.AddFile(fileName, 255); // Act fs.DeleteFile(fileName); // Assert Assert.IsFalse(fs.FileExists(fileName)); }
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 CreateNestedFileFromCurrentDirectory() { // Arrange var fs = new MockFileSystem(); // Act fs.AddFile("test\\test2\\testFile.txt", 352); // Assert Assert.IsTrue(fs.FileExists("c:\\test\\test2\\testFile.txt")); }
public void CreateFileFromAbsolute() { // Arrange var fs = new MockFileSystem(); // Act fs.AddFile("c:\\testFile.txt", 352); // Assert Assert.IsTrue(fs.FileExists("c:\\testFile.txt")); }
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(); }