Ejemplo n.º 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();
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        public void DirectoryExistsReturnsTrueForExistingDirectory()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string newdir = "newdir";
            fs.CreateDirectory(newdir);

            // Act

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

            // Act

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

            // Act
            fs.CreateDirectory(newdir);

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

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

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

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

            // Assert
            Assert.Fail();
        }
Ejemplo n.º 12
0
        public void CreateDirectoryFromCurrent()
        {
            // Arrange
            var fs = new MockFileSystem();

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

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

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

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test"));
        }
Ejemplo n.º 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();
        }