public void AsyncBroacaster_Dispose_Does_Not_Fire_OnCompleted() { var b = new AsyncBroadcaster <int>(); var resetEvent = new ManualResetEvent(false); int count = 0; var sub = b.Subscribe(x => { }, () => { count++; resetEvent.Set(); }); Assert.NotNull(sub); //Dispose will call complete once b.Dispose(); resetEvent.WaitOne(); //ensure it's not called again resetEvent.Reset(); b.OnCompleted(); resetEvent.WaitOne(200); Assert.Equal(1, count); }
public void AsyncBroadcaster_Completed_Subscribe_Does_Not_Add_Observer() { var b = new AsyncBroadcaster <int>(); b.OnCompleted(); b.Subscribe(x => { }); Assert.True(b.IsComplete); Assert.False(b.HasObservers); }
public void AsyncBroacaster_OnCompleted() { var b = new AsyncBroadcaster <int>(); var resetEvent = new ManualResetEvent(false); bool complete = false; var sub = b.Subscribe(x => { }, () => { complete = true; resetEvent.Set(); }); Assert.NotNull(sub); b.OnCompleted(); resetEvent.WaitOne(); Assert.True(complete); }