use super::{
DIContainer, MockContinuationRepository, MockRepositoryBehavior,
MockEffectInterpreter, MockEffectBehavior, MockConfiguration, TestFixture
};
use std::collections::HashMap;
#[derive(Debug)]
pub struct TestFixtureBuilder {
container: DIContainer,
mock_configs: HashMap<String, MockConfiguration>,
}
impl Default for TestFixtureBuilder {
fn default() -> Self {
Self::new()
}
}
impl TestFixtureBuilder {
pub fn new() -> Self {
Self {
container: DIContainer::new(),
mock_configs: HashMap::new(),
}
}
pub fn with_mock_continuation_repository(mut self, behavior: MockRepositoryBehavior) -> Self {
let mock_repo = MockContinuationRepository::with_behavior(behavior.clone());
self.mock_configs.insert("continuation_repository".to_string(), MockConfiguration::Repository(behavior));
self
}
pub fn with_mock_effect_interpreter(mut self, behavior: MockEffectBehavior) -> Self {
let mock_interpreter = MockEffectInterpreter::new();
self.container.register("effect_interpreter", mock_interpreter);
self.mock_configs.insert("effect_interpreter".to_string(), MockConfiguration::EffectInterpreter(behavior));
self
}
pub fn build(self) -> TestFixture {
TestFixture {
container: self.container,
mock_configs: self.mock_configs,
}
}
}