public void Subscribe_MessagesPublished_MessagesReceived()
        {
            int count = 0;

            _messageObservable.Subscribe(_ => count++);

            _publisher.Publish(new TestEventOne());
            _publisher.Publish(new TestEventTwo());
            _publisher.Publish(new TestCommandOne());

            count.Should().Be(2);
        }
Exemplo n.º 2
0
        private Task <SubscribeResult> Subscribe(MessageObserver observer)
        {
            var tcs = new TaskCompletionSource <SubscribeResult>();

            _mqttclient.Subscribe().ContinueWith(t =>
            {
                try
                {
                    _messageObservable.Subscribe(observer);
                    tcs.TrySetResult(t.Result);
                }
                catch (Exception e)
                {
                    tcs.TrySetException(e);
                }
            });

            return(tcs.Task);
        }