zach-delong / FluentAssertions.FileSystem

A simple package providing some easy assertions in the FluentAssertions library for the System.IO.Abstractions.TestingHelpers project

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FluentAssertions.FileSystem

This is a small extension for the popular FluentAssertions library that provides some simple assertions for use with the MockFileSystem type provided by System.IO.Abstractions project.

This package provides a new namespace FluentAssertions.FileSystem that provides an extension method .Should() on the MockFilesystem type provided by System.IO.Abstractions.

The Should method returns an assertions object that has several helpful assertions which can analyze and assert about the MockFilesystem in question.

Example

using System.IO.Abstractions.TestingHelpers;
using FluentAssertions.Filesystem;

public class ExampleUsage 
{
    public void Example()
    {
        var mockFileSystem = new MockFileSystem();

        mockFileSystem
			.AddDirectory("example_directory");

        mockFileSystem
            .Should()
			.ContainDirectory("example_directory");
    }
}

See the provided unit tests for more examples, and the comments in MockFileSystemAssertions for full details about what assertions are available and how to use them.

About

A simple package providing some easy assertions in the FluentAssertions library for the System.IO.Abstractions.TestingHelpers project

License:MIT License


Languages

Language:C# 100.0%