//! Behavioral checks for immutable event-argument mappings generated from the
//! pinned C# constructor assignments.

#![allow(clippy::float_cmp)] // Generated constructor fixtures retain exact values.

use libremetaverse::{MeanCollisionEventArgs, MeanCollisionType, ScriptDialogEventArgs};
use libremetaverse_types::UUID;
use std::time::{Duration, UNIX_EPOCH};

fn id(value: u64) -> UUID {
    UUID::new_with_u_int64(value).expect("UUID")
}

#[test]
fn script_dialog_preserves_constructor_values_and_aliases() {
    let image_id = id(1);
    let object_id = id(2);
    let owner_id = id(3);
    let dialog = ScriptDialogEventArgs::new(
        "Choose".to_owned(),
        "OpenSim object".to_owned(),
        image_id,
        object_id,
        "Grid".to_owned(),
        "Resident".to_owned(),
        -42,
        vec!["Yes".to_owned(), "No".to_owned()],
        owner_id,
    )
    .expect("ScriptDialogEventArgs");

    assert_eq!(dialog.message(), "Choose");
    assert_eq!(dialog.object_name(), "OpenSim object");
    assert_eq!(dialog.image_id(), image_id);
    assert_eq!(dialog.object_id(), object_id);
    assert_eq!(dialog.first_name(), "Grid");
    assert_eq!(dialog.last_name(), "Resident");
    assert_eq!(dialog.channel(), -42);
    assert_eq!(dialog.button_labels(), ["Yes", "No"]);
    assert_eq!(dialog.owner_id(), owner_id);
}

#[test]
fn mean_collision_maps_perp_to_aggressor() {
    let aggressor = id(10);
    let victim = id(11);
    let time = UNIX_EPOCH + Duration::from_secs(1234);
    let collision =
        MeanCollisionEventArgs::new(MeanCollisionType::Bump, aggressor, victim, 2.5, time)
            .expect("MeanCollisionEventArgs");

    assert_eq!(collision.type_(), MeanCollisionType::Bump);
    assert_eq!(collision.aggressor(), aggressor);
    assert_eq!(collision.victim(), victim);
    assert_eq!(collision.magnitude(), 2.5);
    assert_eq!(collision.time(), time);
}
