diff --git a/Cargo.toml b/Cargo.toml index 3b30f6a..aeb3f0a 100755 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,3 +67,4 @@ serde_json = "1.0.81" serde_plain = "1.0.0" # Allow us to assert whether floats are approximately a value assert_approx_eq = "1.1.0" +mockall = "0.11.2" \ No newline at end of file diff --git a/src/dynamic_data/models/learned_move.rs b/src/dynamic_data/models/learned_move.rs index 115461a..99fccfd 100755 --- a/src/dynamic_data/models/learned_move.rs +++ b/src/dynamic_data/models/learned_move.rs @@ -100,22 +100,13 @@ impl ValueIdentifiable for LearnedMove { #[cfg(test)] mod tests { use super::*; - use crate::static_data::{MoveCategory, MoveDataImpl, MoveTarget}; + use crate::static_data::MockMoveData; #[test] fn create_learned_move_restore_uses() { - let data: Arc = Arc::new(MoveDataImpl::new( - &"foo".into(), - 0u8.into(), - MoveCategory::Special, - 100, - 20, - 30, - MoveTarget::All, - 0, - None, - Default::default(), - )); + let mut mock = MockMoveData::new(); + mock.expect_base_usages().return_const(30); + let data: Arc = Arc::new(mock); let learned_move = LearnedMove::new(&data, MoveLearnMethod::Level); assert!(learned_move.try_use(15)); learned_move.restore_uses(5); diff --git a/src/static_data/moves/move_data.rs b/src/static_data/moves/move_data.rs index aed331f..73c6c60 100755 --- a/src/static_data/moves/move_data.rs +++ b/src/static_data/moves/move_data.rs @@ -206,3 +206,27 @@ impl ValueIdentifiable for MoveDataImpl { self.identifier } } + +#[cfg(test)] +mockall::mock! { + #[derive(Debug)] + pub MoveData{} + impl MoveData for MoveData { + fn name(&self) -> &StringKey; + fn move_type(&self) -> TypeIdentifier; + fn category(&self) -> MoveCategory; + fn base_power(&self) -> u8; + fn accuracy(&self) -> u8; + fn base_usages(&self) -> u8; + fn target(&self) -> MoveTarget; + fn priority(&self) -> i8; + fn secondary_effect(&self) -> &Option>; + fn has_flag(&self, key: &StringKey) -> bool; + fn has_flag_by_hash(&self, key_hash: u32) -> bool; + } + impl ValueIdentifiable for MoveData{ + fn value_identifier(&self) -> ValueIdentifier{ + ValueIdentifier::new(0) + } + } +}