pyruse/src/domain/action/noop.rs

39 lines
793 B
Rust
Raw Normal View History

2021-02-20 18:53:11 +01:00
use crate::domain::{Action, ModuleArgs, Record};
2019-11-23 23:10:40 +01:00
pub struct Noop {}
impl Noop {
2021-02-20 18:53:11 +01:00
pub fn from_args(_args: ModuleArgs) -> Noop {
2019-11-23 23:10:40 +01:00
Noop {}
}
}
2019-12-22 13:27:31 +01:00
impl Action for Noop {
fn act(&mut self, _record: &mut Record) -> Result<(), ()> {
2019-12-22 13:27:31 +01:00
Ok(())
2019-11-23 23:10:40 +01:00
}
}
#[cfg(test)]
mod tests {
2021-02-20 18:53:11 +01:00
use crate::domain::action::Noop;
use crate::domain::{Action, ModuleArgs, Record};
2019-11-23 23:10:40 +01:00
use std::collections::HashMap;
2021-02-20 18:53:11 +01:00
fn generate_empty_args_record() -> (ModuleArgs, Record) {
2019-11-23 23:10:40 +01:00
let args = HashMap::with_capacity(0);
let record = HashMap::with_capacity(0);
(args, record)
}
#[test]
fn noop_does_nothing() {
2021-02-20 18:53:11 +01:00
// Given
2019-11-23 23:10:40 +01:00
let (args, mut record) = generate_empty_args_record();
let mut action = Noop::from_args(args);
2021-02-20 18:53:11 +01:00
// Then
2019-12-22 13:27:31 +01:00
assert_eq!((), action.act(&mut record).unwrap());
2019-11-23 23:10:40 +01:00
}
}