public async Task PublisherActionDelegateEventRaisePublishesEventWithPositionalArguments()
        {
            WampPlayground playground = new WampPlayground();

            PublisherSubscriber dualChannel = await playground.GetPublisherSubscriberDualChannel();

            IWampChannel publisher  = dualChannel.Publisher;
            IWampChannel subscriber = dualChannel.Subscriber;

            MyOtherPublisher myPublisher = new MyOtherPublisher();

            IDisposable disposable =
                publisher.RealmProxy.Services.RegisterPublisher
                    (myPublisher);

            IWampTopicProxy topicProxy =
                subscriber.RealmProxy.TopicContainer.GetTopicByUri("com.myapp.mytopic2");

            MyCustomSubscriber myCustomSubscriber = new MyCustomSubscriber();

            IAsyncDisposable subscribe =
                await topicProxy.Subscribe(myCustomSubscriber,
                                           new SubscribeOptions());

            myPublisher.RaiseMyEvent("Hello", 37, 23);

            Assert.That(myCustomSubscriber.ArgumentsKeywords, Is.Null.Or.Empty);

            ISerializedValue[] arguments = myCustomSubscriber.Arguments;

            Assert.That(arguments[0].Deserialize <string>(), Is.EqualTo("Hello"));
            Assert.That(arguments[1].Deserialize <int>(), Is.EqualTo(37));
            Assert.That(arguments[2].Deserialize <int>(), Is.EqualTo(23));
        }
        public async Task PositionalTupleObservableOnNextPublishesEventWithPositionalArguments()
        {
            WampPlayground playground = new WampPlayground();

            PublisherSubscriber dualChannel = await playground.GetPublisherSubscriberDualChannel();

            IWampChannel publisher  = dualChannel.Publisher;
            IWampChannel subscriber = dualChannel.Subscriber;

            var subject =
                publisher.RealmProxy.Services.GetSubject
                    ("com.myapp.mytopic2",
                    new MyPositionalTupleEventConverter());

            IWampTopicProxy topicProxy =
                subscriber.RealmProxy.TopicContainer.GetTopicByUri("com.myapp.mytopic2");

            MyCustomSubscriber myCustomSubscriber = new MyCustomSubscriber();

            IAsyncDisposable subscribe =
                await topicProxy.Subscribe(myCustomSubscriber,
                                           new SubscribeOptions());

            // subject.OnNext(("Hello", 37, 23));
            subject.OnNext(ValueTuple.Create("Hello", 37, 23));

            Assert.That(myCustomSubscriber.ArgumentsKeywords, Is.Null.Or.Empty);

            ISerializedValue[] arguments = myCustomSubscriber.Arguments;

            Assert.That(arguments[0].Deserialize <string>(), Is.EqualTo("Hello"));
            Assert.That(arguments[1].Deserialize <int>(), Is.EqualTo(37));
            Assert.That(arguments[2].Deserialize <int>(), Is.EqualTo(23));
        }
        public async Task PublisherCustomDelegateEventRaisePublishesEventWithKeywordArguments()
        {
            WampPlayground playground = new WampPlayground();

            PublisherSubscriber dualChannel = await playground.GetPublisherSubscriberDualChannel();

            IWampChannel publisher  = dualChannel.Publisher;
            IWampChannel subscriber = dualChannel.Subscriber;

            MyPublisher myPublisher = new MyPublisher();

            IDisposable disposable =
                publisher.RealmProxy.Services.RegisterPublisher
                    (myPublisher);

            IWampTopicProxy topicProxy =
                subscriber.RealmProxy.TopicContainer.GetTopicByUri("com.myapp.topic2");

            MyCustomSubscriber myCustomSubscriber = new MyCustomSubscriber();

            IAsyncDisposable subscribe =
                await topicProxy.Subscribe(myCustomSubscriber,
                                           new SubscribeOptions());

            MyClass instance = new MyClass()
            {
                Counter = 1,
                Foo     = new[] { 1, 2, 3 }
            };

            myPublisher.RaiseMyEvent(37, 23, "Hello", instance);

            Assert.That(myCustomSubscriber.Arguments, Is.Empty);

            IDictionary <string, ISerializedValue> argumentsKeywords =
                myCustomSubscriber.ArgumentsKeywords;

            Assert.That(argumentsKeywords["number1"].Deserialize <int>(), Is.EqualTo(37));
            Assert.That(argumentsKeywords["number2"].Deserialize <int>(), Is.EqualTo(23));
            Assert.That(argumentsKeywords["c"].Deserialize <string>(), Is.EqualTo("Hello"));
            Assert.That(argumentsKeywords["d"].Deserialize <MyClass>(), Is.EqualTo(instance));
        }
        public async Task KeywordTupleObservableOnNextPublishesEventWithPositionalArguments()
        {
            WampPlayground playground = new WampPlayground();

            PublisherSubscriber dualChannel = await playground.GetPublisherSubscriberDualChannel();

            IWampChannel publisher  = dualChannel.Publisher;
            IWampChannel subscriber = dualChannel.Subscriber;

            var subject =
                publisher.RealmProxy.Services.GetSubject
                    ("com.myapp.topic2",
                    new MyKeywordTupleEventConverter());

            IWampTopicProxy topicProxy =
                subscriber.RealmProxy.TopicContainer.GetTopicByUri("com.myapp.topic2");

            MyCustomSubscriber myCustomSubscriber = new MyCustomSubscriber();

            IAsyncDisposable subscribe =
                await topicProxy.Subscribe(myCustomSubscriber,
                                           new SubscribeOptions());

            MyClass instance = new MyClass()
            {
                Counter = 1,
                Foo     = new[] { 1, 2, 3 }
            };

            // subject.OnNext((37, 23, "Hello", instance))
            subject.OnNext(ValueTuple.Create(37, 23, "Hello", instance));

            Assert.That(myCustomSubscriber.Arguments, Is.Empty);

            IDictionary <string, ISerializedValue> argumentsKeywords =
                myCustomSubscriber.ArgumentsKeywords;

            Assert.That(argumentsKeywords["number1"].Deserialize <int>(), Is.EqualTo(37));
            Assert.That(argumentsKeywords["number2"].Deserialize <int>(), Is.EqualTo(23));
            Assert.That(argumentsKeywords["c"].Deserialize <string>(), Is.EqualTo("Hello"));
            Assert.That(argumentsKeywords["d"].Deserialize <MyClass>(), Is.EqualTo(instance));
        }