use super::super::hold::hold;
use super::{advertised, echo, receipt, refusal, restored, row, said, set, wired, work};
use crate::test_support::Notices;
#[test]
fn a_re_assertion_that_wrote_says_the_box_was_disarmed() {
let (notices, sink) = Notices::new();
let (_scratch, _engine, channel) = wired(vec![
advertised(),
work(vec![row("i-1", "Bash")]),
receipt("i-1"),
restored(),
refusal("stop"),
]);
assert_eq!(said(hold(&channel, &set(), echo, &sink, None)), "stop");
let said = notices.heard();
assert_eq!(said.len(), 1, "{said:?}");
assert!(said[0].contains("was not the set in force"), "{said:?}");
assert!(said[0].contains("has just been restored"), "{said:?}");
assert!(
said[0].contains("bearing this box's identity"),
"the sentence names a reading an operator can act on: {said:?}"
);
}
#[test]
fn a_disarming_is_said_and_the_channel_goes_on() {
let (notices, sink) = Notices::new();
let (_scratch, engine, channel) = wired(vec![
advertised(),
work(vec![row("i-1", "Bash")]),
receipt("i-1"),
restored(),
work(vec![]),
refusal("stop"),
]);
assert_eq!(said(hold(&channel, &set(), echo, &sink, None)), "stop");
assert_eq!(
super::ops(&engine),
[
"advertise",
"invocations",
"complete",
"advertise",
"invocations",
"invocations"
],
"it asks for its next work rather than stopping"
);
assert_eq!(notices.heard().len(), 1);
}
#[test]
fn a_re_assertion_that_compared_is_silent() {
let (notices, sink) = Notices::new();
let (_scratch, _engine, channel) = wired(vec![
advertised(),
work(vec![row("i-1", "Bash")]),
receipt("i-1"),
advertised(),
refusal("stop"),
]);
assert_eq!(said(hold(&channel, &set(), echo, &sink, None)), "stop");
assert_eq!(notices.heard(), Vec::<String>::new());
}
#[test]
fn a_write_on_the_first_presentation_is_ordinary_and_silent() {
let (notices, sink) = Notices::new();
let (_scratch, _engine, channel) = wired(vec![restored(), refusal("stop")]);
assert_eq!(said(hold(&channel, &set(), echo, &sink, None)), "stop");
assert_eq!(notices.heard(), Vec::<String>::new());
}
#[test]
fn an_answer_that_is_not_the_receipt_ends_the_channel() {
let (_scratch, _engine, channel) = wired(vec![work(vec![])]);
let said = said(hold(
&channel,
&set(),
echo,
&crate::test_support::aside(),
None,
));
assert!(said.contains("not that the advertisement landed"), "{said}");
assert!(said.contains("Invocations"), "{said}");
}