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