use crate::EntityId;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ContractType {
Import,
Export,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct EnergyContract {
pub id: EntityId,
pub name: String,
pub bus_id: EntityId,
pub contract_type: ContractType,
pub entry_stage_id: Option<i32>,
pub exit_stage_id: Option<i32>,
pub price_per_mwh: f64,
pub min_mw: f64,
pub max_mw: f64,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_import_contract() {
let contract = EnergyContract {
id: EntityId::from(1),
name: "Importação Argentina".to_string(),
bus_id: EntityId::from(5),
contract_type: ContractType::Import,
entry_stage_id: None,
exit_stage_id: None,
price_per_mwh: 200.0,
min_mw: 0.0,
max_mw: 1000.0,
};
assert_eq!(contract.contract_type, ContractType::Import);
assert!(contract.price_per_mwh > 0.0);
}
#[test]
fn test_export_contract() {
let contract = EnergyContract {
id: EntityId::from(2),
name: "Exportação Uruguai".to_string(),
bus_id: EntityId::from(6),
contract_type: ContractType::Export,
entry_stage_id: Some(1),
exit_stage_id: Some(60),
price_per_mwh: -150.0,
min_mw: 0.0,
max_mw: 500.0,
};
assert_eq!(contract.contract_type, ContractType::Export);
assert!(contract.price_per_mwh < 0.0);
}
#[test]
fn test_contract_type_equality() {
assert_eq!(ContractType::Import, ContractType::Import);
assert_eq!(ContractType::Export, ContractType::Export);
assert_ne!(ContractType::Import, ContractType::Export);
}
}