pub mod result;
pub mod stock;
pub use self::result::*;
pub trait Constraint<I> {
#[allow(unused_variables)]
fn handle_call(&mut self, params: &I) { }
fn verify(&self) -> ConstraintResult;
}
pub struct ConstraintMock {
handle_call_expected: bool,
handle_call_called: bool
}
impl ConstraintMock {
pub fn new() -> Self {
Self {
handle_call_expected: false,
handle_call_called: false
}
}
pub fn expect_handle_call(&mut self) {
self.handle_call_expected = true
}
}
impl<I> Constraint<I> for ConstraintMock {
fn handle_call(&mut self, _params: &I) {
self.handle_call_called = true
}
fn verify(&self) -> ConstraintResult {
Ok(())
}
}
impl Drop for ConstraintMock {
fn drop(&mut self) {
if self.handle_call_expected && !self.handle_call_called {
panic!("handle_call was not called");
}
}
}