Skip to content

Commit

Permalink
unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
rruckley committed Oct 12, 2024
1 parent 3dc95e9 commit 7492909
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/common/related_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,27 @@ impl<T : HasName> From<T> for RelatedEntity {
..Default::default()
}
}
}

#[cfg(test)]
mod test {
use crate::tmf651::agreement::Agreement;
use crate::{HasId,HasName};

use super::RelatedEntity;

const AGREEMENT_NAME : &str = "AnAgreement";

#[test]
fn test_relatedentity_from() {
let agreement = Agreement::new(AGREEMENT_NAME);
let agree_ref = &agreement;

let entity = RelatedEntity::from(agreement.clone());

assert_eq!(entity.name,agree_ref.get_name());
assert_eq!(entity.id,agree_ref.get_id().as_str());
assert_eq!(entity.href,agree_ref.get_href().as_str());
assert_eq!(entity.referred_type,Agreement::get_class());
}
}
13 changes: 13 additions & 0 deletions src/tmf667/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ impl From<AttachmentRefOrValue> for Document {
#[cfg(test)]
mod test {
use crate::common::attachment::AttachmentRefOrValue;
use crate::tmf651::agreement::Agreement;
use super::DocumentStatusType;
use super::DOC_VERSION;

Expand All @@ -129,6 +130,7 @@ mod test {
const DOC_NAME : &str = "A Document";
const DOC_TYPE : &str = "PDF";
const DOC_STATE: &str = "\"Created\"";
const AGREEMENT_NAME : &str = "AnAgreement";

#[test]
fn test_document_new() {
Expand Down Expand Up @@ -176,4 +178,15 @@ mod test {

assert_eq!(doc.get_name(),attachref.get_name());
}

#[test]
fn test_document_link() {
let agreement = Agreement::new(AGREEMENT_NAME);

let document = Document::new(AGREEMENT_NAME)
.link(agreement);

assert_eq!(document.related_entity.is_some(),true);
assert_eq!(document.related_entity.unwrap().first().is_some(),true);
}
}

0 comments on commit 7492909

Please sign in to comment.