NuGet.Test.Mocks.MockFileSystem.DirectoryExists C# (CSharp) Method

DirectoryExists() public method

public DirectoryExists ( string path ) : bool
path string
return bool
        public virtual bool DirectoryExists(string path)
        {
            return Paths.Select(file => file.Key)
                        .Any(file => Path.GetDirectoryName(file).Equals(path, StringComparison.OrdinalIgnoreCase));
        }

Usage Example

        public void DeleteFileAndEmptyParentDirectoriesCorrectly()
        {
            // Arrange
            var fileSystem = new MockFileSystem("x:\\");
            fileSystem.AddFile("foo\\bar\\hell\\x.txt");

            // Act
            fileSystem.DeleteFileAndParentDirectoriesIfEmpty("foo\\bar\\hell\\x.txt");

            // Assert
            Assert.False(fileSystem.FileExists("foo\\bar\\hell\\x.txt"));
            Assert.False(fileSystem.DirectoryExists("foo"));
            Assert.False(fileSystem.DirectoryExists("foo\\bar"));
            Assert.False(fileSystem.DirectoryExists("foo\\bar\\hell"));
        }
All Usage Examples Of NuGet.Test.Mocks.MockFileSystem::DirectoryExists