csdif-core 0.1.3

Core library for modeling, validating, and transforming CSDIF data
Documentation
// SPDX-License-Identifier: MIT

//! Unit tests for the transformation logic using the CsdifMapper trait.

use csdif_core::model::{CsdifDocument, Sensor, Observation, Location};
use csdif_core::transform::{transform, CsdifMapper};
use csdif_core::error::CsdifError;

/// Dummy mapper for testing transformation logic.
struct DummyMapper;

impl CsdifMapper for DummyMapper {
    fn to_csdif(&self) -> Result<CsdifDocument, CsdifError> {
        Ok(CsdifDocument {
            sensors: vec![Sensor {
                id: "s1".to_string(),
                sensor_type: "temperature".to_string(),
                unit: "C".to_string(),
                location: Location {
                    latitude: 52.0,
                    longitude: 4.0,
                    elevation: Some(1.0),
                },
            }],
            observations: vec![Observation {
                timestamp: "2025-10-08T08:00:00Z".to_string(),
                value: 21.5,
                sensor_id: "s1".to_string(),
            }],
        })
    }
}

#[test]
fn test_transform_with_dummy_mapper() {
    let mapper = DummyMapper;
    let result = transform(&mapper);
    assert!(result.is_ok());
}