public void Should_return_false_if_there_are_no_subscribers() { Fiber fiber = new SynchronousFiber(); Channel <UserUpdate> channel = new BroadcastChannel <UserUpdate>(new Channel <UserUpdate>[] {}); var update = new UserUpdate(); channel.Send(update); // exception here? or just ignore }
public void Should_return_false_if_there_are_no_subscribers() { Fiber fiber = new SynchronousFiber(); Channel<UserUpdate> channel = new BroadcastChannel<UserUpdate>(new Channel<UserUpdate>[] {}); var update = new UserUpdate(); channel.Send(update); // exception here? or just ignore }
public void Should_filter_out_unwanted_messages() { var update = new UserUpdate {LastActivity = DateTime.Now - 5.Minutes()}; Fiber fiber = new SynchronousFiber(); var future = new FutureChannel<UserUpdate>(); var filter = new FilterChannel<UserUpdate>(fiber, future, x => x.LastActivity > DateTime.Now); Channel<UserUpdate> channel = new BroadcastChannel<UserUpdate>(new[] {filter}); channel.Send(update); Assert.IsFalse(future.WaitUntilCompleted(1.Seconds())); }
public void Should_filter_out_unwanted_messages() { var update = new UserUpdate { LastActivity = DateTime.Now - 5.Minutes() }; Fiber fiber = new SynchronousFiber(); var future = new FutureChannel <UserUpdate>(); var filter = new FilterChannel <UserUpdate>(fiber, future, x => x.LastActivity > DateTime.Now); Channel <UserUpdate> channel = new BroadcastChannel <UserUpdate>(new[] { filter }); channel.Send(update); Assert.IsFalse(future.WaitUntilCompleted(1.Seconds())); }
public void Should_schedule_events() { var update = new UserUpdate {LastActivity = DateTime.Now - 5.Minutes()}; Fiber fiber = new SynchronousFiber(); var future = new FutureChannel<UserUpdate>(); Channel<UserUpdate> channel = new BroadcastChannel<UserUpdate>(new Channel<UserUpdate>[] {future}); var scheduler = new TimerScheduler(fiber); scheduler.Schedule(1000, fiber, () => channel.Send(update)); Thread.Sleep(500); Assert.IsFalse(future.WaitUntilCompleted(0.Seconds())); Assert.IsTrue(future.WaitUntilCompleted(1.Seconds())); }
public void Should_schedule_events() { var update = new UserUpdate { LastActivity = DateTime.Now - 5.Minutes() }; Fiber fiber = new SynchronousFiber(); var future = new FutureChannel <UserUpdate>(); Channel <UserUpdate> channel = new BroadcastChannel <UserUpdate>(new Channel <UserUpdate>[] { future }); var scheduler = new TimerScheduler(fiber); scheduler.Schedule(1000, fiber, () => channel.Send(update)); Thread.Sleep(500); Assert.IsFalse(future.WaitUntilCompleted(0.Seconds())); Assert.IsTrue(future.WaitUntilCompleted(1.Seconds())); }