use micro_games_macros::event_system; #[test] fn event_system_correctly_generates_and_dispatches_events() { use bevy::prelude::*; let mut app = App::new(); #[event_system] enum MyEvents { Wait { source: Entity }, Log { source: Entity, message: String }, } /// A hatch to allow us to assert that the system has actually run, so we don't miss an /// assertion #[derive(Resource)] struct HasRun(bool); app.insert_resource(HasRun(false)); app.add_plugins(MyEventsPlugin); app.add_systems( Update, |mut has_run: ResMut, events: EventReader| { has_run.0 = true; let event_length = events.len(); assert_eq!(event_length, 1); }, ); dispatch_my_events( app.world_mut(), MyEvents::Wait(WaitEvent { source: Entity::from_raw(0), }), ); app.update(); assert!(app.world().resource::().0); }