domain: add cross-cutting value objects (SystemId, DateTimeStamp, Checksum, StructuredData)
This commit is contained in:
31
crates/domain/tests/value_objects/system_id.rs
Normal file
31
crates/domain/tests/value_objects/system_id.rs
Normal file
@@ -0,0 +1,31 @@
|
||||
use domain::value_objects::SystemId;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[test]
|
||||
fn unique_generation() {
|
||||
let a = SystemId::new();
|
||||
let b = SystemId::new();
|
||||
assert_ne!(a, b);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn uuid_roundtrip() {
|
||||
let uuid = Uuid::new_v4();
|
||||
let id = SystemId::from_uuid(uuid);
|
||||
assert_eq!(*id.as_uuid(), uuid);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn display_matches_uuid() {
|
||||
let uuid = Uuid::new_v4();
|
||||
let id = SystemId::from_uuid(uuid);
|
||||
assert_eq!(id.to_string(), uuid.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serde_roundtrip() {
|
||||
let id = SystemId::new();
|
||||
let json = serde_json::to_string(&id).unwrap();
|
||||
let back: SystemId = serde_json::from_str(&json).unwrap();
|
||||
assert_eq!(id, back);
|
||||
}
|
||||
Reference in New Issue
Block a user