IOOverrides class
This class facilitates overriding various APIs of dart:io with mock implementations.
This abstract base class should be extended with overrides for the operations needed to construct mocks. The implementations in this base class default to the actual dart:io implementation. For example:
class MyDirectory implements Directory {
...
// An implementation of the Directory interface
...
}
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. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
createDirectory(
String path) → Directory -
Creates a new Directory object for the given
path
. [...] -
createFile(
String path) → File -
Creates a new File object for the given
path
. [...] -
createLink(
String path) → Link -
Returns a new Link object for the given
path
. [...] -
fseGetType(
String path, bool followLinks) → Future< FileSystemEntityType> -
Asynchronously returns the FileSystemEntityType for
path
. [...] -
fseGetTypeSync(
String path, bool followLinks) → FileSystemEntityType -
Returns the FileSystemEntityType for
path
. [...] -
fseIdentical(
String path1, String path2) → Future< bool> -
Asynchronously returns
true
ifpath1
andpath2
are paths to the same file system object. [...] -
fseIdenticalSync(
String path1, String path2) → bool -
Returns
true
ifpath1
andpath2
are paths to the same file system object. [...] -
fsWatch(
String path, int events, bool recursive) → Stream< FileSystemEvent> - Returns a Stream of FileSystemEvents. [...]
-
fsWatchIsSupported(
) → bool -
Returns
true
when FileSystemEntity.watch is supported. [...] -
getCurrentDirectory(
) → Directory - Returns the current working directory. [...]
-
getSystemTempDirectory(
) → Directory - Returns the system temporary directory. [...]
-
setCurrentDirectory(
String path) → void -
Sets the current working directory to be
path
. [...] -
socketConnect(
dynamic host, int port, { dynamic sourceAddress, Duration timeout }) → Future< Socket> - Asynchronously returns a Socket connected to the given host and port. [...]
-
socketStartConnect(
dynamic host, int port, { dynamic sourceAddress }) → Future< ConnectionTask< Socket>> - Asynchronously returns a ConnectionTask that connects to the given host and port when successful. [...]
-
stat(
String path) → Future< FileStat> -
Asynchronously returns FileStat information for
path
. [...] -
statSync(
String path) → FileStat -
Returns FileStat information for
path
. [...] -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Properties
- current → IOOverrides
-
read-only
- global ← IOOverrides
-
The IOOverrides to use in the root Zone. [...]
write-only
Static Methods
-
runWithIOOverrides<
R>( R body(), IOOverrides overrides, { ZoneSpecification zoneSpecification, Function onError }) → R -
Runs
body
in a fresh Zone using the overrides found inoverrides
. [...] -
runZoned<
R>( R body(), { Directory createDirectory(String), Directory getCurrentDirectory(), void setCurrentDirectory(String), Directory getSystemTempDirectory(), File createFile(String), Future< FileStat> stat(String), FileStat statSync(String), Future< bool> fseIdentical(String, String), bool fseIdenticalSync(String, String), Future< FileSystemEntityType> fseGetType(String, bool), FileSystemEntityType fseGetTypeSync(String, bool), Stream< FileSystemEvent> fsWatch(String, int, bool), bool fsWatchIsSupported(), Link createLink(String), Future< Socket> socketConnect(dynamic, int, { dynamic sourceAddress, Duration timeout }), Future< ConnectionTask< Socket>> socketStartConnect(dynamic, int, { dynamic sourceAddress }), ZoneSpecification zoneSpecification, Function onError }) → R -
Runs
body
in a fresh Zone using the provided overrides. [...]