当前位置: 首页>>代码示例>>C#>>正文


C# MockFileSystem.AddDirectory方法代码示例

本文整理汇总了C#中MockFileSystem.AddDirectory方法的典型用法代码示例。如果您正苦于以下问题:C# MockFileSystem.AddDirectory方法的具体用法?C# MockFileSystem.AddDirectory怎么用?C# MockFileSystem.AddDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MockFileSystem的用法示例。


在下文中一共展示了MockFileSystem.AddDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MockDriveInfoFactory_GetDrives_ShouldReturnDrives

        public void MockDriveInfoFactory_GetDrives_ShouldReturnDrives()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(XFS.Path(@"C:\Test"));
            fileSystem.AddDirectory(XFS.Path(@"Z:\Test"));
            fileSystem.AddDirectory(XFS.Path(@"d:\Test"));
            var factory = new MockDriveInfoFactory(fileSystem);

            // Act
            var actualResults = factory.GetDrives();

            var actualNames = actualResults.Select(d => d.Name);

            // Assert
            Assert.That(actualNames, Is.EquivalentTo(new[] { @"C:\", @"Z:\", @"D:\" }));
        }
开发者ID:johncmckim,项目名称:System.IO.Abstractions,代码行数:17,代码来源:MockDriveInfoFactoryTests.cs

示例2: MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives

        public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives(string driveName)
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
            var path = XFS.Path(driveName);

            // Act
            var driveInfo = new MockDriveInfo(fileSystem, path);

            // Assert
            Assert.AreEqual(@"C:\", driveInfo.Name);
        }
开发者ID:johncmckim,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockDriveInfoTests.cs

示例3: MockDriveInfo_RootDirectory_ShouldReturnTheDirectoryBase

        public void MockDriveInfo_RootDirectory_ShouldReturnTheDirectoryBase()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(XFS.Path(@"c:\Test"));
            var driveInfo = new MockDriveInfo(fileSystem, "c:");
            var expectedDirectory = XFS.Path(@"C:\");

            // Act
            var actualDirectory = driveInfo.RootDirectory;

            // Assert
            Assert.AreEqual(expectedDirectory, actualDirectory.FullName);
        }
开发者ID:johncmckim,项目名称:System.IO.Abstractions,代码行数:14,代码来源:MockDriveInfoTests.cs

示例4: MockFile_AppendAllText_ShouldCreateIfNotExistWithBom

        public void MockFile_AppendAllText_ShouldCreateIfNotExistWithBom()
        {
            // Arrange
            var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>());
            const string path = @"c:\something\demo3.txt";
            fileSystem.AddDirectory(@"c:\something\");

            // Act
            fileSystem.File.AppendAllText(path, "AA", Encoding.UTF32);

            // Assert
            CollectionAssert.AreEqual(
                new byte[] {255, 254, 0, 0, 65, 0, 0, 0, 65, 0, 0, 0},
                fileSystem.GetFile(path).Contents);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:15,代码来源:MockFileAppendAllTextTests.cs

示例5: MockFile_WriteAllBytes_ShouldWriteDataToMemoryFileSystem

        public void MockFile_WriteAllBytes_ShouldWriteDataToMemoryFileSystem()
        {
            // Arrange
            string path = XFS.Path(@"c:\something\demo.txt");
            var fileSystem = new MockFileSystem();
            var fileContent = new byte[] { 1, 2, 3, 4 };
            fileSystem.AddDirectory(@"c:\something");

            // Act
            fileSystem.File.WriteAllBytes(path, fileContent);

            // Assert
            Assert.AreEqual(
                fileContent,
                fileSystem.GetFile(path).Contents);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:16,代码来源:MockFileWriteAllBytesTests.cs

示例6: MockFile_WriteAllText_ShouldOverriteAnExistingFile

        public void MockFile_WriteAllText_ShouldOverriteAnExistingFile()
        {
            // http://msdn.microsoft.com/en-us/library/ms143375.aspx

            // Arrange
            string path = XFS.Path(@"c:\something\demo.txt");
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(@"c:\something");

            // Act
            fileSystem.File.WriteAllText(path, "foo");
            fileSystem.File.WriteAllText(path, "bar");

            // Assert
            Assert.AreEqual("bar", fileSystem.GetFile(path).TextContents);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:16,代码来源:MockFileWriteAllTextTests.cs

示例7: MockFile_WriteAllText_ShouldNotThrowAnArgumentNullExceptionIfTheContentIsNull

        public void MockFile_WriteAllText_ShouldNotThrowAnArgumentNullExceptionIfTheContentIsNull()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            string directoryPath = XFS.Path(@"c:\something");
            string filePath = XFS.Path(@"c:\something\demo.txt");
            fileSystem.AddDirectory(directoryPath);

            // Act
            fileSystem.File.WriteAllText(filePath, null);

            // Assert
            // no exception should be thrown, also the documentation says so
            var data = fileSystem.GetFile(filePath);
            Assert.That(data.Contents, Is.Empty);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:16,代码来源:MockFileWriteAllTextTests.cs

示例8: MockFile_WriteAllText_ShouldWriteTextFileToMemoryFileSystem

        public void MockFile_WriteAllText_ShouldWriteTextFileToMemoryFileSystem()
        {
            // Arrange
            string path = XFS.Path(@"c:\something\demo.txt");
            string fileContent = "Hello there!";
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(@"c:\something");

            // Act
            fileSystem.File.WriteAllText(path, fileContent);

            // Assert
            Assert.AreEqual(
                fileContent,
                fileSystem.GetFile(path).TextContents);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:16,代码来源:MockFileWriteAllTextTests.cs

示例9: MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives_SpecialForWindows

        public void MockDriveInfo_Constructor_ShouldInitializeLocalWindowsDrives_SpecialForWindows()
        {
            if (XFS.IsUnixPlatform())
            {
                Assert.Inconclusive("Using XFS.Path transform c into c:.");
            }

            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(XFS.Path(@"c:\Test"));

            // Act
            var driveInfo = new MockDriveInfo(fileSystem, "c");

            // Assert
            Assert.AreEqual(@"C:\", driveInfo.Name);
        }
开发者ID:johncmckim,项目名称:System.IO.Abstractions,代码行数:17,代码来源:MockDriveInfoTests.cs

示例10: MockDirectory_GetDirectories_WithTopDirectories_ShouldOnlyReturnTopDirectories

        public void MockDirectory_GetDirectories_WithTopDirectories_ShouldOnlyReturnTopDirectories()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(XFS.Path(@"C:\Folder\.foo\"));
            fileSystem.AddDirectory(XFS.Path(@"C:\Folder\foo"));
            fileSystem.AddDirectory(XFS.Path(@"C:\Folder\foo.foo"));
            fileSystem.AddDirectory(XFS.Path(@"C:\Folder\.foo\.foo"));
            fileSystem.AddFile(XFS.Path(@"C:\Folder\.foo\bar"), new MockFileData(string.Empty));

            // Act
            var actualResult = fileSystem.Directory.GetDirectories(XFS.Path(@"c:\Folder\"), "*.foo");

            // Assert
            Assert.That(actualResult, Is.EquivalentTo(new []{XFS.Path(@"C:\Folder\.foo\"), XFS.Path(@"C:\Folder\foo.foo\")}));
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:16,代码来源:MockDirectoryTests.cs

示例11: MockDirectory_GetFiles_ShouldThrowAnArgumentException_IfSearchPatternHasIllegalCharacters

        public void MockDirectory_GetFiles_ShouldThrowAnArgumentException_IfSearchPatternHasIllegalCharacters(string searchPattern)
        {
            // Arrange
            var directoryPath = XFS.Path(@"c:\Foo");
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(directoryPath);

            // Act
            TestDelegate action = () => fileSystem.Directory.GetFiles(directoryPath, searchPattern);

            // Assert
            Assert.Throws<ArgumentException>(action);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockDirectoryTests.cs

示例12: MockDirectory_GetFiles_ShouldThrowAnArgumentException_IfSearchPatternEndsWithTwoDots

        public void MockDirectory_GetFiles_ShouldThrowAnArgumentException_IfSearchPatternEndsWithTwoDots()
        {
            // Arrange
            var directoryPath = XFS.Path(@"c:\Foo");
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(directoryPath);

            // Act
            TestDelegate action = () => fileSystem.Directory.GetFiles(directoryPath, "*a..");

            // Assert
            Assert.Throws<ArgumentException>(action);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockDirectoryTests.cs

示例13: MockDirectory_Move_ShouldThrowAnIOExceptionIfDirectoriesAreOnDifferentVolumes

        public void MockDirectory_Move_ShouldThrowAnIOExceptionIfDirectoriesAreOnDifferentVolumes()
        {
            // Arrange
            string sourcePath = XFS.Path(@"c:\a");
            string destPath = XFS.Path(@"d:\v");
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(sourcePath);

            // Act
            TestDelegate action = () => fileSystem.Directory.Move(sourcePath, destPath);

            // Assert
            Assert.Throws<IOException>(action, "Source and destination path must have identical roots. Move will not work across volumes.");
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:14,代码来源:MockDirectoryTests.cs

示例14: MockDirectory_Move_ShouldThrowAnIOExceptionIfBothPathAreIdentical

        public void MockDirectory_Move_ShouldThrowAnIOExceptionIfBothPathAreIdentical()
        {
            // Arrange
            string path = XFS.Path(@"c:\a");
            var fileSystem = new MockFileSystem();
            fileSystem.AddDirectory(path);

            // Act
            TestDelegate action = () => fileSystem.Directory.Move(path, path);

            // Assert
            Assert.Throws<IOException>(action, "Source and destination path must be different.");
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockDirectoryTests.cs

示例15: MockFile_WriteAllText_ShouldThrowAnUnauthorizedAccessExceptionIfThePathIsOneDirectory

        public void MockFile_WriteAllText_ShouldThrowAnUnauthorizedAccessExceptionIfThePathIsOneDirectory()
        {
            // Arrange
            var fileSystem = new MockFileSystem();
            string directoryPath = XFS.Path(@"c:\something");
            fileSystem.AddDirectory(directoryPath);

            // Act
            TestDelegate action = () => fileSystem.File.WriteAllText(directoryPath, null);

            // Assert
            Assert.Throws<UnauthorizedAccessException>(action);
        }
开发者ID:tathamoddie,项目名称:System.IO.Abstractions,代码行数:13,代码来源:MockFileWriteAllTextTests.cs


注:本文中的MockFileSystem.AddDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。