public async void Subscription_is_idempotent_and_callback_will_be_overriden() { const string grainId = "222"; using (var proxy = await ReactiveObservableProxy.Create()) { var received = new AutoResetEvent(false); string source = null; FooPublished @event = null; var first = await proxy.Attach(grainId, typeof(FooPublished)); Debug.Assert(first != null); var observable = await proxy.Attach(grainId, typeof(FooPublished)); observable.Subscribe(e => { source = e.Source; @event = e.Payload.Message as FooPublished; received.Set(); }); await bus.Send(grainId, new PublishFoo("foo")); received.WaitOne(TimeSpan.FromSeconds(5)); Assert.NotNull(@event); Assert.AreEqual("foo", @event.Foo); Assert.AreEqual(grainId, source); } }
/// <summary> /// Creates new <see cref="IReactiveObservableProxy"/> /// </summary> /// <returns>New instance of <see cref="IReactiveObservableProxy"/></returns> public static async Task <IReactiveObservableProxy> Create() { var observable = new ReactiveObservableProxy(); var proxy = await SubscriptionManager.Instance.CreateProxy(observable); observable.Initialize(proxy); return(observable); }