#[cfg(not(target_family = "wasm"))]
use rmcp::{ServerHandler, model::ProtocolVersion};
#[cfg(not(target_family = "wasm"))]
use rudof_mcp::service::RudofMcpService;
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_service_creation() {
let service = RudofMcpService::try_new();
assert!(service.is_ok(), "Service should be created successfully");
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_service_default() {
let _service = RudofMcpService::default();
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_server_info_has_required_fields() {
let service = RudofMcpService::new();
let info = service.get_info();
assert_eq!(
info.protocol_version,
ProtocolVersion::LATEST,
"Protocol version should be the latest MCP version"
);
assert!(
!info.server_info.name.is_empty(),
"Server implementation name should not be empty"
);
assert!(
info.instructions.is_some(),
"Instructions should be provided for LLM context"
);
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_tools_capability_advertised() {
let service = RudofMcpService::new();
let info = service.get_info();
assert!(
info.capabilities.tools.is_some(),
"Tools capability should be advertised"
);
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_prompts_capability_advertised() {
let service = RudofMcpService::new();
let info = service.get_info();
assert!(
info.capabilities.prompts.is_some(),
"Prompts capability should be advertised"
);
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_resources_capability_advertised() {
let service = RudofMcpService::new();
let info = service.get_info();
let resources_cap = info
.capabilities
.resources
.expect("Resources capability should be advertised");
assert_eq!(
resources_cap.subscribe,
Some(false),
"Resource subscription is not yet implemented"
);
assert_eq!(
resources_cap.list_changed,
Some(false),
"Resource list_changed notifications are not yet implemented"
);
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_logging_capability_advertised() {
let service = RudofMcpService::new();
let info = service.get_info();
let logging = info
.capabilities
.logging
.expect("Logging capability should be advertised");
assert!(logging.is_empty(), "Logging capability should be declared as an object");
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_completions_capability_advertised() {
let service = RudofMcpService::new();
let info = service.get_info();
assert!(
info.capabilities.completions.is_some(),
"Completions capability should be advertised"
);
}
#[cfg(not(target_family = "wasm"))]
#[test]
fn test_no_experimental_capabilities() {
let service = RudofMcpService::new();
let info = service.get_info();
assert!(
info.capabilities.experimental.is_none(),
"Experimental capabilities should not be set unless needed"
);
}