darwin-metrics 0.1.5

A Rust library exposing native macOS system metrics
use objc2_foundation::{NSDictionary, NSObject, NSString};

use crate::utils::property_utils::{PropertyAccessor, PropertyUtils};
use crate::utils::test_utils::create_test_dictionary;

// Create a simple mock implementation for testing
struct MockPropertyUtils;

impl PropertyUtils for MockPropertyUtils {
    // Override the default implementations to provide test behavior
}

#[test]
fn test_property_utils_trait() {
    // This test verifies that the PropertyUtils trait methods work as expected
    // by implementing a mock that uses the default trait implementations

    // Create a test dictionary
    let dict = create_test_dictionary();

    // The default implementations will return None for any key since our test
    // dictionary is empty, which is fine for this test
    let string_result = MockPropertyUtils::get_string_property(&dict, "test_key");
    let number_result = MockPropertyUtils::get_number_property(&dict, "test_key");
    let bool_result = MockPropertyUtils::get_bool_property(&dict, "test_key");

    // Since our test dictionary is empty, all results should be None
    assert_eq!(string_result, None);
    assert_eq!(number_result, None);
    assert_eq!(bool_result, None);
}

#[test]
fn test_property_accessor_implements_trait() {
    // This test verifies that PropertyAccessor implements PropertyUtils
    // by checking that the trait methods can be assigned to function pointers
    // with the correct signatures

    let _: fn(&NSDictionary<NSString, NSObject>, &str) -> Option<String> =
        PropertyAccessor::get_string_property;
    let _: fn(&NSDictionary<NSString, NSObject>, &str) -> Option<f64> =
        PropertyAccessor::get_number_property;
    let _: fn(&NSDictionary<NSString, NSObject>, &str) -> Option<bool> =
        PropertyAccessor::get_bool_property;

    // No assertion needed - test passes if it compiles successfully
}