public async Task ShouldRecieveOnNextNotification() { var leaderEndpoint = new IPEndPoint(IPAddress.Loopback, 40000); Bot leader = new Bot( null, "leader", leaderEndpoint); EventWaitHandle fired = new EventWaitHandle(false, EventResetMode.ManualReset); leader.Subscribe(Observer.Create<string>(x => fired.Set())); await leader.StartAttack("address"); if(!fired.WaitOne(1000)) { Assert.False(true); } }
public async Task ShouldRecieveMultipleNextNotification() { var leaderEndpoint = new IPEndPoint(IPAddress.Loopback, 40000); Bot leader = new Bot( null, "leader", leaderEndpoint); EventWaitHandle[] fired = new EventWaitHandle[10]; for(int i=0; i<fired.Length; i++) { var closure = i; fired[i] = new EventWaitHandle(false, EventResetMode.ManualReset); leader.Subscribe(Observer.Create<string>(x => fired[closure].Set())); } await leader.StartAttack("address"); if (!WaitHandle.WaitAll(fired, 1000)) { Assert.False(true); } }