use crate::prelude::*;
#[derive(
Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Deref, From, Getters, Builder,
)]
pub struct ItemConvertedIntoTargetCurrency {
#[deref]
#[serde(flatten)]
in_source_currency: Item,
#[getset(get = "pub")]
total_cost: Cost,
}
impl HasSample for ItemConvertedIntoTargetCurrency {
fn sample() -> Self {
Self::builder()
.in_source_currency(Item::sample())
.total_cost(Cost::sample())
.build()
}
fn sample_other() -> Self {
Self::builder()
.in_source_currency(Item::sample_other())
.total_cost(Cost::sample_other())
.build()
}
}
#[cfg(test)]
mod tests {
use super::*;
use test_log::test;
type Sut = ItemConvertedIntoTargetCurrency;
#[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());
}
#[test]
fn item_converted_into_target_currency_sample() {
let sample = Sut::sample();
assert_eq!(*sample.total_cost(), Cost::sample());
}
}