use crate::prelude::*;
#[derive(Clone, Debug, PartialEq, Eq, Hash, Builder, Getters)]
pub struct NamedPdf {
#[getset(get = "pub")]
prepared_data: PreparedData,
#[getset(get = "pub")]
pdf: Pdf,
#[getset(get = "pub")]
saved_at: PathBuf,
#[getset(get = "pub")]
name: String,
}
impl HasSample for NamedPdf {
fn sample() -> Self {
Self::builder()
.prepared_data(PreparedData::sample())
.pdf(Pdf::sample()) .saved_at(PathBuf::from("/tmp/sample_invoice.pdf"))
.name("sample_invoice.pdf".to_string())
.build()
}
fn sample_other() -> Self {
Self::builder()
.prepared_data(PreparedData::sample_other())
.pdf(Pdf::sample_other()) .saved_at(PathBuf::from("/tmp/another_invoice.pdf"))
.name("another_invoice.pdf".to_string())
.build()
}
}
#[cfg(test)]
mod tests {
use super::*;
type Sut = NamedPdf;
#[test]
fn equality() {
assert_eq!(Sut::sample(), Sut::sample());
assert_eq!(Sut::sample_other(), Sut::sample_other());
}
#[test]
fn inequality() {
assert_ne!(Sut::sample(), Sut::sample_other());
}
}