LoneElementCollectionWrapper

org.scalatest.LoneElement.LoneElementCollectionWrapper
final class LoneElementCollectionWrapper[E, CTC[_]](collection: CTC[E], collecting: Collecting[E, CTC[E]], prettifier: Prettifier, pos: Position)

Wrapper class that adds a loneElement method to any collection type C for which an implicit Collecting[C] is available.

Through the implicit conversion provided by trait LoneElement, this class allows you to make statements like:

trav.loneElement should be > 9

Type parameters

CTC

the "collection type constructor" for the collection on which to add the loneElement method

E

the element type of the collection on which to add the loneElement method

Value parameters

collecting

a typeclass that enables the loneElement syntax

collection

a collection to wrap in a LoneElementCollectionWrapper, which provides the loneElement method.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def loneElement: E

Returns the value contained in the wrapped collection, if it contains one and only one element, else throws TestFailedException with a detail message describing the problem.

Returns the value contained in the wrapped collection, if it contains one and only one element, else throws TestFailedException with a detail message describing the problem.

This method enables syntax such as the following:

trav.loneElement should be > 9
    ^

Attributes