Facilities for overriding various APIs ofdart:io with mockimplementations.
This abstract base class should be extended with overrides for theoperations needed to construct mocks. The implementations in this base classdefault to the actualdart:io implementation. For example:
class MyDirectory implements Directory { ... // An implementation of the Directory interface ...}void main() { IOOverrides.runZoned(() { ... // Operations will use MyDirectory instead of dart:io's Directory // implementation whenever Directory is used. ... }, createDirectory: (String path) => new MyDirectory(path));}Constructors
Properties
- hashCode→int
- The hash code for this object.no setterinherited
- runtimeType→Type
- A representation of the runtime type of the object.no setterinherited
- stderr→Stdout
- The standard output stream of errors written by this program.no setter
- stdin→Stdin
- The standard input stream of data read by this program.no setter
- stdout→Stdout
- The standard output stream of data written by this program.no setter
Methods
- createDirectory(
Stringpath)→Directory - Creates a newDirectory object for the given
path. - createFile(
Stringpath)→File - Creates a newFile object for the given
path. - createLink(
Stringpath)→Link - Returns a newLink object for the given
path. - exit(
intcode)→ Never - Exit the Dart VM process immediately with the given exit code.
- fseGetType(
Stringpath,boolfollowLinks)→Future< FileSystemEntityType> - Asynchronously returns theFileSystemEntityType for
path. - fseGetTypeSync(
Stringpath,boolfollowLinks)→FileSystemEntityType - Returns theFileSystemEntityType for
path. - fseIdentical(
Stringpath1,Stringpath2)→Future< bool> - Asynchronously returns
trueifpath1andpath2are paths to thesame file system object. - fseIdenticalSync(
Stringpath1,Stringpath2)→bool - Returns
trueifpath1andpath2are paths to thesame file system object. - fsWatch(
Stringpath,intevents,boolrecursive)→Stream< FileSystemEvent> - Returns aStream ofFileSystemEvents.
- fsWatchIsSupported(
)→bool - Returns
truewhenFileSystemEntity.watch is supported. - getCurrentDirectory(
)→Directory - Returns the current working directory.
- getSystemTempDirectory(
)→Directory - Returns the system temporary directory.
- noSuchMethod(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- serverSocketBind(
dynamicaddress,intport, {intbacklog =0,boolv6Only =false,boolshared =false})→Future< ServerSocket> - Asynchronously returns aServerSocket that connects to the given addressand port when successful.
- setCurrentDirectory(
Stringpath)→ void - Sets the current working directory to be
path. - socketConnect(
dynamichost,intport, {dynamicsourceAddress,intsourcePort =0,Duration?timeout})→Future< Socket> - Asynchronously returns aSocket connected to the given host and port.
- socketStartConnect(
dynamichost,intport, {dynamicsourceAddress,intsourcePort =0})→Future< ConnectionTask< Socket> > - Asynchronously returns aConnectionTask that connects to the given hostand port when successful.
- stat(
Stringpath)→Future< FileStat> - Asynchronously returnsFileStat information for
path. - statSync(
Stringpath)→FileStat - ReturnsFileStat information for
path. - toString(
)→String - A string representation of this object.inherited
Operators
- operator ==(
Objectother)→bool - The equality operator.inherited
Static Properties
- current→IOOverrides?
- no setter
- global←IOOverrides?
- TheIOOverrides to use in the rootZone.no getter
Static Methods
- runWithIOOverrides<
R> (Rbody(),IOOverridesoverrides)→ R - Runs
bodyin a freshZone using the overrides found inoverrides. - runZoned<
R> (Rbody(), {DirectorycreateDirectory(String)?,DirectorygetCurrentDirectory()?,voidsetCurrentDirectory(String)?,DirectorygetSystemTempDirectory()?,FilecreateFile(String)?,Future< FileStat> stat(String)?,FileStatstatSync(String)?,Future<bool> fseIdentical(String,String)?,boolfseIdenticalSync(String,String)?,Future<FileSystemEntityType> fseGetType(String,bool)?,FileSystemEntityTypefseGetTypeSync(String,bool)?,Stream<FileSystemEvent> fsWatch(String,int,bool)?,boolfsWatchIsSupported()?,LinkcreateLink(String)?,Future<Socket> socketConnect(dynamic,int, {dynamicsourceAddress,intsourcePort,Duration?timeout})?,Future<ConnectionTask< socketStartConnect(dynamic,int, {dynamicsourceAddress,intsourcePort})?,Future<Socket> >ServerSocket> serverSocketBind(dynamic,int, {intbacklog,boolshared,boolv6Only})?,Stdinstdin()?,Stdoutstdout()?,Stdoutstderr()?,Neverexit(int)?})→ R - Runs
bodyin a freshZone using the provided overrides.