Esempio 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();
        }
Esempio 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));
        }
Esempio n. 3
0
        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();
        }
Esempio n. 4
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();
        }
Esempio n. 5
0
        public void FileDelete_DeletingNonExistantFileDoesNotFail()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string fileName = "c:\\test\\Horker.txt";

            // Act
            fs.DeleteFile(fileName);

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

            // Act

            // Assert
            Assert.IsTrue(fs.DirectoryExists(newdir));
        }
Esempio n. 8
0
        public void DirectoryExistsReturnsFalseForNonexistingDirectory()
        {
            // Arrange
            var fs = new MockFileSystem();

            // Act
            bool result = fs.DirectoryExists("doesnotexist");

            // Assert
            Assert.IsFalse(result);
        }
Esempio n. 9
0
        public void CreateDirectoryFromCurrent()
        {
            // Arrange
            var fs = new MockFileSystem();

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

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test"));
        }
Esempio n. 10
0
        public void InstantiateMockFileSystem()
        {
            // Arrange

            // Act
            var fs = new MockFileSystem();

            // Assert
            Assert.IsNotNull(fs);
        }
Esempio n. 11
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));
        }
Esempio n. 12
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();
        }
Esempio n. 13
0
        public void CreateSimpleDirectoryAfterInstantiate()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string newdir = "newdir";

            // Act
            fs.CreateDirectory(newdir);

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

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

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test\\test2"));
        }
Esempio n. 16
0
        public void CreateFileFromAbsolute()
        {
            // Arrange
            var fs = new MockFileSystem();

            // Act
            fs.AddFile("c:\\testFile.txt", 352);

            // Assert
            Assert.IsTrue(fs.FileExists("c:\\testFile.txt"));
        }
Esempio n. 17
0
        public void CreateExistingDirectoryThrowsIoException()
        {
            // Arrange
            var fs = new MockFileSystem();
            fs.CreateDirectory("test");

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

            // Assert
            Assert.Fail();
        }
Esempio n. 18
0
        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));
        }
Esempio n. 19
0
        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);
        }
Esempio n. 20
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();
        }
Esempio n. 21
0
        public void InstantiateMockFileSystemHasValidCurrentDirectorySet()
        {
            // Arrange

            // Act
            var fs = new MockFileSystem();

            // Assert
            Assert.IsNotNull(fs.GetCurrentDirectory());
            Assert.IsTrue(fs.GetCurrentDirectory().Length >= 3);
            Assert.IsTrue(Regex.IsMatch(fs.GetCurrentDirectory(), "[A-Za-z]:\\.*", RegexOptions.IgnoreCase));
        }
Esempio n. 22
0
        public void CreateAbsoluteDirectoryFromExistingDriveWithTrailingSlash()
        {
            // Arrange
            var fs = new MockFileSystem();

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

            // Assert
            Assert.IsTrue(fs.DirectoryExists("c:\\test"));
        }
Esempio n. 23
0
        public void DirectoryExistsIsCaseInsensitive()
        {
            // Arrange
            var fs = new MockFileSystem();
            fs.CreateDirectory("test\\test2");

            // Act

            // Assert
            Assert.IsTrue(fs.DirectoryExists("C:\\TEST\\test2"));
        }
Esempio n. 24
0
        public void CopyFile_NonExistantFromFileThrowsFileNotFoundException()
        {
            // Arrange
            var fs = new MockFileSystem();
            const string oldFilePath = "c:\\old\\file1.txt";
            //long oldSize = 100;
            const string newFilePath = "c:\\new\\file2.txt";
            //long newSize = 300;

            // Act
            fs.CopyFile(oldFilePath, newFilePath);

            // Assert
            Assert.Fail();
        }