Exemplo n.º 1
0
            public async Task ShouldRemoveHandlerFromSubscribers()
            {
                _channel.Subscribe(_handler);
                _channel.Unsubscribe(_handler);
                await _client.FakeMessageReceived(new Message("test", "best"), _channel.Name);

                //Handler should not throw
            }
Exemplo n.º 2
0
            public async Task WithNoArguments_AddsAListenerForAllMessages()
            {
                var channel = _client.Channels.Get("Test");

                SetState(channel, ChannelState.Attached);
                var messages = new List <Message>();
                int count    = 0;

                channel.Subscribe(message =>
                {
                    messages.Add(message);
                    count++;
                    if (count == 2)
                    {
                        Done();
                    }
                });

                await _client.FakeMessageReceived(new Message("test", "best"), "Test");

                await _client.FakeMessageReceived(new Message("", "best"), "Test");

                await _client.FakeMessageReceived(new Message("blah", "best"), "Test");

                WaitOne();

                messages.Should().HaveCount(3);
            }