MSTestExtensions/FileAssert.cs
/// <summary>
/// Asserts that all bytes in the file are within the ASCII range.
/// </summary>
/// <param name="assert"><see cref="Assert.That"/></param>
/// <param name="path">The path to the file.</param>
Asserts that all bytes in the file are within the ASCII range.
Asserts that all bytes in the file are within the ASCII range .
public static void FileIsAsciiOnly(this Assert assert, string path)
        {
            FileExists(assert, path);
            using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read))
            {
                if (stream.ReadByte() > 0x7F)
                {
                    throw new AssertFailedException($"Invalid character at byte {stream.Position - 1}");
                }
            }
        }
public static void FileIsAsciiOnly ( this Assert assert , string path ) { FileExists ( assert , path ) ; using ( var stream = new FileStream ( path , FileMode . Open , FileAccess . Read ) ) { if ( stream . ReadByte ( ) > 0x7F ) { throw new AssertFailedException ( $" Invalid character at byte  { stream . Position - 1 } " ) ; } } }
Asserts that all bytes in the file are within the ASCII range.
Asserts that all bytes in the file are within the ASCII range .
Assert
this
path
string
The path to the file.
The path to the file .
assert
None