use super::*;
#[test]
fn test_application_can_be_created_with_different_modules() {
let _app1 = Application::new(EmptyModule);
#[cfg(not(feature = "thread-safe"))]
let _app2 = Application::new(CountingModule {
counter: Rc::new(RefCell::new(0)),
});
#[cfg(feature = "thread-safe")]
let _app2 = Application::new(CountingModule {
counter: Arc::new(Mutex::new(0)),
});
}
#[test]
fn test_injector_accessible_before_bootstrap() {
let app = Application::new(EmptyModule);
let _injector = app.injector();
}
#[test]
fn test_multiple_injector_clones() {
let mut app = Application::new(EmptyModule);
app.bootstrap_sync().unwrap();
let injectors: Vec<_> = (0..5).map(|_| app.injector()).collect();
assert_eq!(injectors.len(), 5);
#[cfg(feature = "thread-safe")]
assert_eq!(std::sync::Arc::strong_count(&injectors[0]), 6);
#[cfg(not(feature = "thread-safe"))]
assert_eq!(std::rc::Rc::strong_count(&injectors[0]), 6); }
#[cfg(feature = "debug")]
#[test]
fn test_debug_implementation() {
let app = Application::new(EmptyModule);
let debug_str = format!("{:?}", app);
assert!(
debug_str.contains("Application"),
"Debug output should contain 'Application'"
);
}
#[test]
fn test_deeply_nested_modules() {
#[cfg(not(feature = "thread-safe"))]
let counter = Rc::new(RefCell::new(0));
#[cfg(feature = "thread-safe")]
let counter = Arc::new(Mutex::new(0));
let module = NestedImportModule {
counter: counter.clone(),
depth: 5,
};
let mut app = Application::new(module);
app.bootstrap_sync().unwrap();
#[cfg(not(feature = "thread-safe"))]
assert_eq!(*counter.borrow(), 6, "All nested modules should be loaded");
#[cfg(feature = "thread-safe")]
assert_eq!(
*counter.lock().unwrap(),
6,
"All nested modules should be loaded"
);
}