doc / ch.tutteli.atrium.api.infix.en_GB / toBe

toBe

infix fun <T> Expect<T>.toBe(expected: T): Expect<T> (source)

Expects that the subject of this expectation is (equal to) expected.

expect(12) toBe 12 // holds

fails {
    expect(12) toBe 11
}

// holds, toBe is based on equality, use isSameAs for identity
expect(listOf(1)) toBe listOf(1)

fails { // because array has not implemented equals, so is equivalent to isSameAs
    expect(arrayOf(1)) toBe arrayOf(1)
}

Return
an Expect for the subject of this expectation.

infix fun <T : CharSequence> Expect<T>.toBe(empty: empty): Expect<T> (source)

Expects that the subject of this expectation (a CharSequence) CharSequence.kotlin.text.isEmpty.

expect("") toBe empty

fails {
    expect("XYZ") toBe empty
}

Parameters

empty - Use the pseudo-keyword empty.

Return
This assertion container to support a fluent API.

@JvmName("toBeNull") infix fun <T : BigDecimal> Expect<T?>.toBe(expected: Nothing?): Expect<T?> (source)

Expects that the subject of this expectation (a BigDecimal) is null.

Return
an Expect for the subject of this expectation.

infix fun <E, T : Optional<E>> Expect<T>.toBe(present: present): FeatureExpect<T, E> (source)

Expects that the subject of this expectation (an Optional) is present and returns an Expect for the inner type E.

Shortcut for more or less something like feature(Optional<T>::get) but with error handling; yet it depends on the underlying implementation though.

Return
The newly created Expect for the inner type E.

Since
0.12.0

infix fun <E, T : Optional<E>> Expect<T>.toBe(present: PresentWithCreator<E>): Expect<T> (source)

Expects that the subject of this expectation (an Optional) is present and that it holds all assertions the given PresentWithCreator.assertionCreator creates.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.toBe(existing: existing): Expect<T> (source)

Expects that the subject of this expectation (a Path) exists; meaning that there is a file system entry at the location the Path points to.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, then the search will continue at that location.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.toBe(readable: readable): Expect<T> (source)

Expects that the subject of this expectation (a Path) is readable; meaning that there is a file system entry at the location the Path points to and that the current thread has the permission to read from it.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

This assertion is not atomic with respect to concurrent file system operations on the paths the assertion works on. Its result, in particular its extended explanations, may be wrong if such concurrent file system operations take place.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.toBe(writable: writable): Expect<T> (source)

Expects that the subject of this expectation (a Path) is writable; meaning that there is a file system entry at the location the Path points to and that the current thread has the permission to write to it.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.toBe(executable: executable): Expect<T> (source)

Expects that the subject of this expectation (a Path) is executable; meaning that there is a file system entry at the location the Path points to and that the current thread has the permission to execute it.

The semantics of “permission to execute it” may differ when checking access to a directory. For example, on UNIX systems, it means that the Java virtual machine has permission to search the directory in order to access file or subdirectories.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

Return
an Expect for the subject of this expectation.

Since
0.14.0

infix fun <T : Path> Expect<T>.toBe(aRegularFile: aRegularFile): Expect<T> (source)

Expects that the subject of this expectation (a Path) is a file; meaning that there is a file system entry at the location the Path points to and that is a regular file.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

This assertion is not atomic with respect to concurrent file system operations on the paths the assertion works on. Its result, in particular its extended explanations, may be wrong if such concurrent file system operations take place.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.toBe(aDirectory: aDirectory): Expect<T> (source)

Expects that the subject of this expectation (a Path) is a directory; meaning that there is a file system entry at the location the Path points to and that is a directory.

This assertion resolves symbolic links. Therefore, if a symbolic link exists at the location the subject points to, search will continue at the location the link points at.

This assertion is not atomic with respect to concurrent file system operations on the paths the assertion9 works on. Its result, in particular its extended explanations, may be wrong if such concurrent file system operations take place.

Return
an Expect for the subject of this expectation.

Since
0.12.0

infix fun <T : Path> Expect<T>.toBe(aSymbolicLink: aSymbolicLink): Expect<T> (source)

Expects that the subject of this expectation (a Path) is a symbolic link; meaning that there is a file system entry at the location the Path points to and that is a symbolic link.

This assertion is not atomic with respect to concurrent file system operations on the paths the assertion works on. Its result, in particular its extended explanations, may be wrong if such concurrent file system operations take place.

val target = tempDir.newFile("target")
val link = Files.createSymbolicLink(tempDir.resolve("link"), target)

// Passes, as subject `link` is a symbolic link
expect(link) toBe aSymbolicLink

val file = tempDir.newFile("somePath")
fails { // Fails, as subject `path` is a not a symbolic link
    expect(file) toBe aSymbolicLink
}

Return
an Expect for the subject of this expectation.

Since
0.16.0

infix fun <T : Path> Expect<T>.toBe(absolute: absolute): Expect<T> (source)

Expects that the subject of this expectation (a Path) is an absolute path; meaning that the Path specified in this instance starts at the file system root.

Return
an Expect for the subject of this expectation.

Since
0.14.0

infix fun <T : Path> Expect<T>.toBe(relative: relative): Expect<T> (source)

Expects that the subject of this expectation (a Path) is a relative path; meaning that the Path specified in this instance does not start at the file system root.

Return
an Expect for the subject of this expectation.

Since
0.14.0

infix fun <T : Path> Expect<T>.toBe(anEmptyDirectory: anEmptyDirectory): Expect<T> (source)

Expects that the subject of this expectation (a Path) is an empty directory; meaning that there is a file system entry at the location the Path points to and that is an empty directory.

val path = tempDir.newDirectory("dir")
expect(path) toBe anEmptyDirectory

Return
an Expect for the subject of this expectation.

Since
0.16.0