// Exact Rust translation of LibreMetaverse.Tests/RLV/PermissionsTests.cs.

use libremetaverse_compat_tests::rlv_support::{RlvHarness, guid};
use libremetaverse_rlv::{
    RlvPermissionsServiceHoverTextLocation as HoverTextLocation,
    RlvPermissionsServiceObjectLocation as ObjectLocation,
};

fn harness() -> RlvHarness {
    RlvHarness::new().expect("RlvService constructor")
}

fn hover_text_defaults() -> [bool; 2] {
    let permissions = harness().service.permissions();
    let object = Some(Some(guid("00000000-0000-4000-8000-000000000000")));
    [
        permissions
            .can_show_hover_text(HoverTextLocation::World, object)
            .unwrap(),
        permissions
            .can_show_hover_text(HoverTextLocation::Hud, object)
            .unwrap(),
    ]
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CamZoomMin_Default::test 662b332d66c72caecc1a179730bc2524b9da16aa85f7289bebd31842610ceccc translated
#[test]
fn camera_zoom_min_defaults_to_none() {
    assert!(
        harness()
            .service
            .permissions()
            .get_camera_restrictions()
            .unwrap()
            .zoom_min()
            .flatten()
            .is_none()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShowHoverTextWorld_Default::test 380d1e30bd9ded04329bfd6d65ba447a8dd45a934cfa875628253719bb0e69ce translated
#[test]
fn can_show_hover_text_world_defaults_true() {
    assert_eq!(hover_text_defaults(), [true, true]);
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShowHoverTextHud_Default::test a0af1f72f417cfa451284b7a3dbbb26d378e7eb9896dde3b6df0d0a2e4773f38 translated
#[test]
fn can_show_hover_text_hud_defaults_true() {
    assert_eq!(hover_text_defaults(), [true, true]);
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShowHoverText_Default::test c4122dbf650f51bde55dfda412a884347a78d3cd09dd2bb0fcbe4a7e74a1fff6 translated
#[test]
fn can_show_hover_text_defaults_true() {
    assert_eq!(hover_text_defaults(), [true, true]);
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShowHoverTextAll_Default::test 0ed67c5566d038f770eb9f5df6aa0b5394d7d94cf7c397fa8089b419f872c681 translated
#[test]
fn can_show_all_hover_text_defaults_true() {
    assert_eq!(hover_text_defaults(), [true, true]);
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShowNameTags_Default::test 0781be94eb099d9aed1be2ff313856770d1ec24047d04c81c69219c743b4c8cb translated
#[test]
fn can_show_name_tags_defaults_true() {
    let permissions = harness().service.permissions();
    assert!(permissions.can_show_name_tags(None).unwrap());
    assert!(
        permissions
            .can_show_name_tags(Some(Some(guid("aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"))))
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShare_Default::test e827d549d1d9329b63db159446937735ead13eed5d3eaa59440d3c686182f517 translated
#[test]
fn can_share_defaults_true() {
    let permissions = harness().service.permissions();
    assert!(permissions.can_share(None).unwrap());
    assert!(
        permissions
            .can_share(Some(Some(guid("aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"))))
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanShowNames_Default::test 56492cdd0802c5f8ed2a0f6d56abaf8186e37dd7b888904db52be97f9137279a translated
#[test]
fn can_show_names_defaults_true() {
    let permissions = harness().service.permissions();
    assert!(permissions.can_show_names(None).unwrap());
    assert!(
        permissions
            .can_show_names(Some(Some(guid("aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"))))
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanEdit_Default::test 417fb9f3eb3e70f3bd33710d11fb25eacd0db0a365b0ed2dec6778d09968f44b translated
#[test]
fn can_edit_defaults_true_for_all_locations_and_ids() {
    let permissions = harness().service.permissions();
    let object = Some(Some(guid("00000000-0000-4000-8000-000000000000")));
    for location in [
        ObjectLocation::Hud,
        ObjectLocation::Attached,
        ObjectLocation::RezzedInWorld,
    ] {
        assert!(permissions.can_edit(location, None).unwrap());
        assert!(permissions.can_edit(location, object).unwrap());
    }
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanRecvChat_Default::test b1ec48da83249b1141c3af926cd494373c47214d6a145916a8833d49edd155e2 translated
#[test]
fn can_receive_chat_defaults_true() {
    let permissions = harness().service.permissions();
    assert!(
        permissions
            .can_receive_chat(
                "Hello world".into(),
                guid("aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"),
            )
            .unwrap()
    );
    assert!(
        permissions
            .can_receive_chat(
                "/me says Hello world".into(),
                guid("bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbbb"),
            )
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanAutoAcceptTpRequest_Default::test abbcccb4415afdb6558f40a6d4030704f64442f019d065fef8a7a56a407e8642 translated
#[test]
fn auto_accept_tp_request_defaults_false() {
    let permissions = harness().service.permissions();
    for user in [
        Some(Some(guid("00000000-0000-4000-8000-000000000000"))),
        Some(Some(guid("11111111-1111-4111-8111-111111111111"))),
        None,
    ] {
        assert!(!permissions.is_auto_accept_tp_request(user).unwrap());
    }
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanTpRequest_Default::test aefc51023a5274d402dae0e8111a0776622dc431754c3d1f0ce240a50dfd405d translated
#[test]
fn can_tp_request_defaults_true() {
    let permissions = harness().service.permissions();
    assert!(permissions.can_tp_request(None).unwrap());
    assert!(
        permissions
            .can_tp_request(Some(Some(guid("aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa"))))
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanAutoAcceptTp_Default::test 553245a5381689a7f1c6398cb0ca50510f9089b9bdc797672ae35fb5822fdf8e translated
#[test]
fn auto_accept_tp_defaults_false() {
    let permissions = harness().service.permissions();
    for user in [
        Some(Some(guid("00000000-0000-4000-8000-000000000000"))),
        Some(Some(guid("11111111-1111-4111-8111-111111111111"))),
        None,
    ] {
        assert!(!permissions.is_auto_accept_tp(user).unwrap());
    }
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanChat_Default::test a9b0e4f8713991ce8b9b61d750c086d56da432dbddd533ec63dc0604238831a1 translated
#[test]
fn can_chat_defaults_true() {
    let permissions = harness().service.permissions();
    for (channel, message) in [(0, "Hello"), (0, "/me says Hello"), (5, "Hello")] {
        assert!(permissions.can_chat(channel, message.into()).unwrap());
    }
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanSendIM_Default::test 6cc5238ded59b80408c59c9e77ded1162e370c295b846903dbcc87f74175cd55 translated
#[test]
fn can_send_im_defaults_true() {
    let permissions = harness().service.permissions();
    let user = Some(Some(guid("00000000-0000-4000-8000-000000000000")));
    assert!(permissions.can_send_im("Hello".into(), user, None).unwrap());
    assert!(
        permissions
            .can_send_im("Hello".into(), user, Some("Group Name".into()))
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanStartIM_Default::test c6d6db79b0939b33eb5fd29490474575e062f796160f4a69aab34ccefc1842cb translated
#[test]
fn can_start_im_defaults_true() {
    assert!(
        harness()
            .service
            .permissions()
            .can_start_im(guid("00000000-0000-4000-8000-000000000000"))
            .unwrap()
    );
}

// parity-case: LibreMetaverse.Tests/RLV/PermissionsTests.cs::PermissionsTests.CanReceiveIM_Default::test 23c1c79ae9eba016a48f3e9097fc26283223c9e120308d93fe53ce591ee5691c translated
#[test]
fn can_receive_im_defaults_true() {
    let permissions = harness().service.permissions();
    let user = Some(Some(guid("00000000-0000-4000-8000-000000000000")));
    assert!(
        permissions
            .can_receive_im("Hello".into(), user, None)
            .unwrap()
    );
    assert!(
        permissions
            .can_receive_im("Hello".into(), user, Some("Group Name".into()))
            .unwrap()
    );
}
