public async Task RunAsyncOnStartFalse() { var config = new object(); var manager = Substitute.For <IRoleTaskManager <object> >(); manager.OnStart(config).Returns(false); var rs = new RoleServiceFake <object>(manager, config); await rs.RunTest(CancellationToken.None); manager.Received().OnStart(config); }
public async Task RunAsyncWithLoop() { var config = new object(); var manager = Substitute.For <IRoleTaskManager <object> >(); manager.OnStart(config).Returns(true); var rs = new RoleServiceFake <object>(manager, config); var ct = new CancellationTokenSource(); using (var t = new Timer(new TimerCallback((object obj) => { ct.Cancel(); }), null, 3, Timeout.Infinite)) { await rs.RunTest(ct.Token); manager.Received().OnStart(config); manager.Received().Run(); manager.Received().OnStop(); } }