Search Results for

    Show / Hide Table of Contents

    FileAssert

    The FileAssert class provides methods for comparing or verifying the existence of files, which may be provided as Streams, as FileInfos or as strings giving the path to each file.

    FileAssert is in the NUnit.Framework namespace, so using NUnit.Framework; is enough. It ships in nunit.framework.legacy.dll, which is part of the NUnit package.

    Note

    In NUnit 4, FileAssert was in the NUnit.Framework.Legacy namespace and needed using NUnit.Framework.Legacy;.

    FileAssert.AreEqual(Stream expected, Stream actual);
    FileAssert.AreEqual(
        Stream expected, Stream actual, string message, params object[] args);
    
    FileAssert.AreEqual(FileInfo expected, FileInfo actual);
    FileAssert.AreEqual(
        FileInfo expected, FileInfo actual, string message, params object[] args);
    
    FileAssert.AreEqual(string expected, string actual);
    FileAssert.AreEqual(
        string expected, string actual, string message, params object[] args);
    
    FileAssert.AreNotEqual(Stream expected, Stream actual);
    FileAssert.AreNotEqual(
        Stream expected, Stream actual, string message, params object[] args);
    
    FileAssert.AreNotEqual(FileInfo expected, FileInfo actual);
    FileAssert.AreNotEqual(
        FileInfo expected, FileInfo actual, string message, params object[] args);
    
    FileAssert.AreNotEqual(string expected, string actual);
    FileAssert.AreNotEqual(
        string expected, string actual, string message, params object[] args);
    
    FileAssert.Exists(FileInfo actual);
    FileAssert.Exists(
        FileInfo actual, string message, params object[] args);
    
    FileAssert.Exists(string actual);
    FileAssert.Exists(
        string actual, string message, params object[] args);
    
    FileAssert.DoesNotExist(FileInfo actual);
    FileAssert.DoesNotExist(
        FileInfo actual, string message, params object[] args);
    
    FileAssert.DoesNotExist(string actual);
    FileAssert.DoesNotExist(
        string actual, string message, params object[] args);
    

    See Also

    • File and Directory Constraints
    • Edit this page
    In this article
    Back to top Generated by DocFX | Copyright (c) 2018- The NUnit Project - Licensed under CC BY-NC-SA 4.0