Test updates.

This commit is contained in:
2026-09-29 22:35:03 +02:00
parent 3858dd7216
commit f7e3fc5342
5 changed files with 153 additions and 109 deletions
+36
View File
@@ -26,3 +26,39 @@ impl From<domain::Direction> for Direction {
}
}
}
#[cfg(test)]
mod tests {
use super::Direction;
use crate::domain;
#[test]
fn serializes_direction() {
assert_eq!(serde_json::to_value(Direction::In).unwrap(), "in");
assert_eq!(serde_json::to_value(Direction::Out).unwrap(), "out");
}
#[test]
fn deserializes_direction() {
let incoming: Direction = serde_json::from_value("in".into()).unwrap();
assert!(matches!(incoming, Direction::In));
let outgoing: Direction = serde_json::from_value("out".into()).unwrap();
assert!(matches!(outgoing, Direction::Out));
}
#[test]
fn converts_between_dto_and_domain() {
let domain_in: domain::Direction = Direction::In.into();
assert_eq!(domain_in, domain::Direction::In);
let domain_out: domain::Direction = Direction::Out.into();
assert_eq!(domain_out, domain::Direction::Out);
let dto_in: Direction = domain::Direction::In.into();
assert!(matches!(dto_in, Direction::In));
let dto_out: Direction = domain::Direction::Out.into();
assert!(matches!(dto_out, Direction::Out));
}
}