Table of Contents

Struct Times

Namespace
Moq
Assembly
Moq.dll

Defines the number of invocations allowed by a mocked method.

public readonly struct Times : IEquatable<Times>
Implements
Inherited Members

Methods

AtLeast(int)

Specifies that a mocked method should be invoked callCount times as minimum.

public static Times AtLeast(int callCount)

Parameters

callCount int

The minimum number of times.

Returns

Times

An object defining the allowed number of invocations.

AtLeastOnce()

Specifies that a mocked method should be invoked one time as minimum.

public static Times AtLeastOnce()

Returns

Times

An object defining the allowed number of invocations.

AtMost(int)

Specifies that a mocked method should be invoked callCount times as maximum.

public static Times AtMost(int callCount)

Parameters

callCount int

The maximum number of times.

Returns

Times

An object defining the allowed number of invocations.

AtMostOnce()

Specifies that a mocked method should be invoked one time as maximum.

public static Times AtMostOnce()

Returns

Times

An object defining the allowed number of invocations.

Between(int, int, Range)

Specifies that a mocked method should be invoked between callCountFrom and callCountTo times.

public static Times Between(int callCountFrom, int callCountTo, Range rangeKind)

Parameters

callCountFrom int

The minimum number of times.

callCountTo int

The maximum number of times.

rangeKind Range

The kind of range. See Range.

Returns

Times

An object defining the allowed number of invocations.

Deconstruct(out int, out int)

Deconstructs this instance.

public void Deconstruct(out int from, out int to)

Parameters

from int

This output parameter will receive the minimum required number of calls satisfying this instance (i.e. the lower inclusive bound).

to int

This output parameter will receive the maximum allowed number of calls satisfying this instance (i.e. the upper inclusive bound).

Equals(Times)

Returns a value indicating whether this instance is equal to a specified Times value.

public bool Equals(Times other)

Parameters

other Times

A Times value to compare to this instance.

Returns

bool

true if other has the same value as this instance; otherwise, false.

Equals(object)

Returns a value indicating whether this instance is equal to a specified Times value.

public override bool Equals(object obj)

Parameters

obj object

An object to compare to this instance.

Returns

bool

true if obj has the same value as this instance; otherwise, false.

Exactly(int)

Specifies that a mocked method should be invoked exactly callCount times.

public static Times Exactly(int callCount)

Parameters

callCount int

The times that a method or property can be called.

Returns

Times

An object defining the allowed number of invocations.

GetHashCode()

Returns a hash code for this instance.

public override int GetHashCode()

Returns

int

A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.

Never()

Specifies that a mocked method should not be invoked.

public static Times Never()

Returns

Times

An object defining the allowed number of invocations.

Once()

Specifies that a mocked method should be invoked exactly one time.

public static Times Once()

Returns

Times

An object defining the allowed number of invocations.

ToString()

public override string ToString()

Returns

string

Validate(int)

Checks whether the specified number of invocations matches the constraint described by this instance.

public bool Validate(int count)

Parameters

count int

The number of invocations to check.

Returns

bool

true if count matches the constraint described by this instance; otherwise, false.

Operators

operator ==(Times, Times)

Determines whether two specified Times objects have the same value.

public static bool operator ==(Times left, Times right)

Parameters

left Times

The first Times.

right Times

The second Times.

Returns

bool

true if left has the same value as right; otherwise, false.

operator !=(Times, Times)

Determines whether two specified Times objects have different values.

public static bool operator !=(Times left, Times right)

Parameters

left Times

The first Times.

right Times

The second Times.

Returns

bool

true if the value of left is different from right's; otherwise, false.