MSTestExtensions/FileAssert.cs
/// <summary>
/// Asserts that a file contains a string.
/// </summary>
/// <param name="assert"><see cref="Assert.That"/></param>
/// <param name="path">The path to the file to check.</param>
/// <param name="expected">The expected string.</param>
/// <param name="encoding">The encoding of the string to search for.</param>
Asserts that a file contains a string.
Asserts that a file contains a string .
public static void FileContainsString(this Assert assert, string path, string expected, Encoding encoding)
        {
            Assert.IsNotNull(expected, "Attempted to assert that file contains null string");
            Assert.IsNotNull(encoding, $"Attempted to call {nameof(FileAssert)}.{nameof(FileContainsString)} with a null encoding.");
            byte[] textBytes = encoding.GetBytes(expected);
            if (!InternalContainsBytes(path, textBytes))
            {
                throw new AssertFailedException("File does not contain the expected string, \"\".");
            }
        }
public static void FileContainsString ( this Assert assert , string path , string expected , Encoding encoding ) { Assert . IsNotNull ( expected , " " ) ; Assert . IsNotNull ( encoding , $" Attempted to call  { nameof ( FileAssert ) } . { nameof ( FileContainsString ) }  with a null encoding. " ) ; byte [ ] textBytes = encoding . GetBytes ( expected ) ; if ( ! InternalContainsBytes ( path , textBytes ) ) { throw new AssertFailedException ( " \" \" " ) ; } }
Asserts that a file contains a string.
Asserts that a file contains a string .
Assert
this
path
string
The path to the file to check.
The path to the file to check .
expected
string
The expected string.
The expected string .
encoding
Encoding
The encoding of the string to search for.
The encoding of the string to search for .
assert
None