use libremetaverse::assets::gltf::GltfDocument;
use libremetaverse::assets::{ArchiveConstants, AssetTexture, OarFile};
use libremetaverse::import_export::ModelPrim;
use libremetaverse::materials::LegacyMaterial;
use libremetaverse::messages::linden::AgentDropGroupMessage;
use libremetaverse::packets::UseCircuitCodePacket;
use libremetaverse::{BitPack, PacketFrequency, PermissionMask, Permissions, Primitive};

#[test]
fn each_wire_data_domain_is_callable_at_its_native_boundary() {
    let packet = UseCircuitCodePacket::new_with_constructor()
        .expect("generated packet constructor is native");
    assert_eq!(packet.circuit_code.code, 0);
    assert!(
        AgentDropGroupMessage::new()
            .expect("native generated message constructor")
            .agent_data_block
            .is_empty()
    );
    assert_eq!(
        AssetTexture::new_with_constructor()
            .expect("native asset texture constructor")
            .components,
        0
    );
    assert_eq!(
        GltfDocument::new()
            .expect("native glTF constructor")
            .version(),
        "2.0"
    );
    assert!(
        ModelPrim::new()
            .expect("native model constructor")
            .asset
            .is_empty()
    );
    assert_eq!(
        OarFile::package_archive(String::new(), String::new()),
        Err(libremetaverse::Error::InvalidOperation)
    );
    let bit_pack = BitPack::new(Vec::new(), 0).expect("native bit pack constructor");
    assert_eq!(bit_pack.byte_pos(), 0);
    assert_eq!(bit_pack.bit_pos(), 0);
    assert_eq!(
        Permissions::new(0, 0, 0, 0, 0).expect("native permissions constructor"),
        Permissions::no_permissions()
    );
}

#[test]
fn object_model_domains_are_native() {
    assert_eq!(
        Primitive::new_with_constructor()
            .expect("native primitive constructor")
            .local_id,
        0
    );
    assert_eq!(
        LegacyMaterial::new_with_constructor()
            .expect("native legacy material constructor")
            .id(),
        libremetaverse_types::UUID::zero()
    );
}

#[test]
fn wire_widths_flags_and_constants_match_the_catalog() {
    assert_eq!(PacketFrequency::High as u8, 2);
    assert_eq!(PermissionMask::COPY.0, 32_768);
    assert_eq!(ArchiveConstants::ASSETS_PATH, "assets/");
    assert_eq!(
        libremetaverse::PrimitiveParticleSystem::LEGACY_DATA_BLOCK_SIZE,
        86
    );
}
