示例#1
0
        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();
        }
示例#2
0
        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));
        }
示例#3
0
        public void FileDelete_OnDirectoryThrowsUnauthorizedAccessException()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string fileName = "c:\\test\\";
            fs.CreateDirectory(fileName);

            // Act
            fs.DeleteFile(fileName);

            // Assert
            Assert.Fail();
        }
示例#4
0
        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);
        }
示例#5
0
        public void DirectoryExistsReturnsTrueForExistingDirectory()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string newdir = "newdir";
            fs.CreateDirectory(newdir);

            // Act

            // Assert
            Assert.IsTrue(fs.DirectoryExists(newdir));
        }
示例#6
0
        public void DirectoryExistsIsCaseInsensitive()
        {
            // Arrange
            var fs = new MockFileSystem();
            fs.CreateDirectory("test\\test2");

            // Act

            // Assert
            Assert.IsTrue(fs.DirectoryExists("C:\\TEST\\test2"));
        }
示例#7
0
        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));
        }
示例#8
0
        public void CreateSimpleDirectoryAfterInstantiate()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string newdir = "newdir";

            // Act
            fs.CreateDirectory(newdir);

            // Assert
            Assert.IsTrue(fs.DirectoryExists(newdir));
        }
示例#9
0
        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();
        }
示例#10
0
        public void CreateNestedDirectoryFromCurrentWithTrailingSlash()
        {
            // Arrange
            var fs = new MockFileSystem();

            // Act
            fs.CreateDirectory("test\\test2\\");

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test\\test2"));
        }
示例#11
0
        public void CreateExistingDirectoryThrowsIoException()
        {
            // Arrange
            var fs = new MockFileSystem();
            fs.CreateDirectory("test");

            // Act
            fs.CreateDirectory("test");

            // Assert
            Assert.Fail();
        }
示例#12
0
        public void CreateDirectoryFromCurrent()
        {
            // Arrange
            var fs = new MockFileSystem();

            // Act
            fs.CreateDirectory("test");

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test"));
        }
示例#13
0
        public void CreateAbsoluteDirectoryFromExistingDriveWithTrailingSlash()
        {
            // Arrange
            var fs = new MockFileSystem();

            // Act
            fs.CreateDirectory("c:\\test\\");

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test"));
        }
示例#14
0
        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();
        }