[][src]Macro faux::when

when!() { /* proc-macro */ }

Creates a When instance to mock a specific method in a struct.

The method to mock must be be in an impl blocked tagged by #[methods]

#[faux::create]
pub struct Foo {}

#[faux::methods]
impl Foo {
    pub fn some_method(&self, a: u32, b: i8) -> i32 {
        /* implementation code */
    }
}

fn main() {
    let mut mock = Foo::faux();
    // (u32, i8) is the input of the mocked method
    // i32 is the output of the mocked method
    let a: faux::When<(u32, i8), i32> = faux::when!(mock.some_method);
}