Struct cqrs_es2::ConsumerTester [−][src]
pub struct ConsumerTester<C: ICommand, E: IEvent, Q: Debug + Default + Clone + PartialEq + IEventConsumer<C, E>> { /* fields omitted */ }
Expand description
ConsumerTester
provides a consistent way to test query
implementations
Examples
use cqrs_es2::{
example_impl::{
CustomerCommand,
CustomerContactQuery,
CustomerEvent,
EmailUpdated,
NameAdded,
},
ConsumerTester,
EventContext,
};
type CustomTester = ConsumerTester<
CustomerCommand,
CustomerEvent,
CustomerContactQuery,
>;
CustomTester::default()
.given_no_previous_state()
.when(&EventContext::new(
"".to_string(),
0,
CustomerEvent::NameAdded(NameAdded {
changed_name: "John Doe".to_string(),
}),
Default::default(),
))
.then_expect(CustomerContactQuery {
name: "John Doe".to_string(),
email: "".to_string(),
latest_address: "".to_string(),
});
CustomTester::default()
.given(CustomerContactQuery {
name: "John Doe".to_string(),
email: "".to_string(),
latest_address: "".to_string(),
})
.when(&EventContext::new(
"".to_string(),
0,
CustomerEvent::EmailUpdated(EmailUpdated {
new_email: "j@d.com".to_string(),
}),
Default::default(),
))
.then_expect(CustomerContactQuery {
name: "John Doe".to_string(),
email: "j@d.com".to_string(),
latest_address: "".to_string(),
});
Implementations
impl<C: ICommand, E: IEvent, Q: Debug + Default + Clone + PartialEq + IEventConsumer<C, E>> ConsumerTester<C, E, Q>
impl<C: ICommand, E: IEvent, Q: Debug + Default + Clone + PartialEq + IEventConsumer<C, E>> ConsumerTester<C, E, Q>
Initiates a projection test with no previous state