Trait galvanic_mock_lib::MockControl [] [src]

pub trait MockControl {
    fn should_verify_on_drop(&mut self, flag: bool);
fn add_given_behaviour(
        &self,
        requested_trait: &'static str,
        method: &'static str,
        behaviour: GivenBehaviour
    );
fn reset_given_behaviours(&mut self);
fn add_expect_behaviour(
        &self,
        requested_trait: &'static str,
        method: &'static str,
        behaviour: ExpectBehaviour
    );
fn reset_expected_behaviours(&mut self);
fn are_expected_behaviours_satisfied(&self) -> bool;
fn verify(&self); }

A trait for controlling the behaviour of a mock.

All mocks generated by galvanic-mock implement this trait. The generated mocks use a MockState object internally to handle the state of the mock. The mock's implementation of the MockControl trait acts as a proxy to the MockState object.

Required Methods

Passing true enables verification of expected behaviours when the mock object is dropped.

See verify().

For internal use only.

Enables a behaviour defined in a given!-block for a trait's method.

Arguments

  • requested_trait - the trait's name
  • method - the trait's method's name
  • behaviour - the behaviour to be activated

Deactivates all behaviours activated by a given!-block before.

For internal use only.

Enables a behaviour defined in a expect_interactions!-block for a trait's method.

Arguments

  • requested_trait - the trait's name
  • method - the trait's method's name
  • behaviour - the behaviour to be activated

Deactivates all behaviours activated by a expect_interactions!-block before.

Returns true iff all expected interactions with the mock have occurred.

Panics if some expected interaction with the mock has not occurred.

An expected interaction is defined by a behaviour added to the mock in an expect_interactions!-block. A behaviour is said to match if the method asocciated with the behaviour is called with values satisfying the behaviour's argument pattern. A behaviour is satisfied if its expected repetitions are fulfilled.

Verification should be skipped if the current thread is already panicking. This method should also be executed once the implementor is drpped if verication on drop is enabled.

Implementors