【发布时间】:2017-09-14 07:26:33
【问题描述】:
我有一个测试,可能会响应一些意外消息,但最终它必须响应特定的已知消息。 所以本质上我想要一个断言,它会在某个时间跨度内忽略其他消息,但期望一个已知消息,如下所示:
[TestMethod]
[TestCategory("Integration")]
public async Task Should_fetch_fund_shareclass_and_details_from_test_service()
{
var testIsins = new HashSet<string> {"isin1", "isin2", "isin3"};
var props = Props.Create(() => new DataFetchSupervisor());
var actor = Sys.ActorOf(props, "fetchSupervisor");
Within(TimeSpan.FromSeconds(30), () =>
{
actor.Tell(new StartDataFetch(testIsins));
//ignore unexpected messages here
var fetchComplteMsg = ExpectMsg<DataFetchComplete>();
});
}
所以现在这将失败,因为我在 DataFetchComplete 消息之前收到了一些其他消息。
一如既往,提前感谢您的帮助。
【问题讨论】: