Ejemplo n.º 1
0
        public void channel_broadcasts_only_to_subbed_users()
        {
            IBackStore store = new BackStore();

            store.Subscribe("user-1", "channel-1");
            store.Subscribe("user-2", "channel-2");

            var ret = store.PushBroadcast("user-1", "channel-1", "broadcast message");

            Assert.Contains(store.UserMessages("user-1"), itm => itm.Id == ret.Item2);
            Assert.DoesNotContain(store.UserMessages("user-2"), itm => itm.Id == ret.Item2);
        }
Ejemplo n.º 2
0
        public void broadcast_creates_message_other_users_can_see()
        {
            IBackStore store = new BackStore();

            store.Subscribe("user-1", "channel-1");
            store.Subscribe("user-2", "channel-1");

            var ret = store.PushBroadcast("user-1", "channel-1", "broadcast message");

            Assert.Contains(store.UserMessages("user-1"), itm => itm.Id == ret.Item2);
            Assert.Contains(store.UserMessages("user-2"), itm => itm.Id == ret.Item2);
        }
Ejemplo n.º 3
0
        public void channel_broadcast_has_messages_from_multiple_users()
        {
            IBackStore store = new BackStore();

            store.Subscribe("user-1", "channel-1");
            store.Subscribe("user-2", "channel-1");

            var ret1 = store.PushBroadcast("user-1", "channel-1", "broadcast message 1");
            var ret2 = store.PushBroadcast("user-2", "channel-1", "broadcast message 2");

            Assert.Contains(store.ChannelMessages("channel-1"), itm => itm.Id == ret1.Item2);
            Assert.Contains(store.ChannelMessages("channel-1"), itm => itm.Id == ret2.Item2);
        }
Ejemplo n.º 4
0
        public void direct_message_sends_only_direct_doesnot_touch_channel()
        {
            IBackStore store = new BackStore();

            store.Subscribe("user-1", "channel-1");
            store.Subscribe("user-2", "channel-2");
            store.Subscribe("user-3", "channel-1");
            store.Subscribe("user-3", "channel-2");

            var ret1 = store.PushDirect("user-1", "user-2", "DM 1");
            var ret2 = store.PushDirect("user-2", "user-3", "DM 2");

            Assert.DoesNotContain(store.ChannelMessages("chanel-1"), itm => itm.Id == ret1.Item2);
            Assert.DoesNotContain(store.ChannelMessages("chanel-1"), itm => itm.Id == ret2.Item2);
        }
Ejemplo n.º 5
0
        public void subscribe_should_add_channel_and_user(string username_, string channel_)
        {
            IBackStore store = new BackStore();

            Assert.DoesNotContain(channel_, store.Channels);
            Assert.DoesNotContain(username_, store.Users);
            Assert.DoesNotContain(username_, store.ChannelUsers(channel_));

            store.Subscribe(username_, channel_);

            Assert.Contains(channel_, store.Channels);
            Assert.Contains(username_, store.Users);
            Assert.Contains(username_, store.ChannelUsers(channel_));
        }
Ejemplo n.º 6
0
        public void broadcast_into_subbed_chan_returns_Ok(string username_, string channel_)
        {
            IBackStore store = new BackStore();

            Assert.DoesNotContain(username_, store.Users);
            Assert.DoesNotContain(username_, store.ChannelUsers(channel_));

            store.Subscribe(username_, channel_);
            Assert.Contains(username_, store.ChannelUsers(channel_));

            var ret = store.PushBroadcast(username_, channel_, "broadcast message");

            Assert.Equal(eOpStatus.Ok, ret.Item1.code);
        }
Ejemplo n.º 7
0
        public void mismatched_unsubscribe_should_return_Ok()
        {
            IBackStore store = new BackStore();

            var data  = UserChannelData().ToList();
            var u2ch1 = data[1];

            foreach (var pair in data)
            {
                store.Subscribe(pair[0], pair[1]);
            }

            Assert.DoesNotContain(u2ch1[0], store.ChannelUsers("dummy-chan"));

            var ret = store.UnSubscribe(u2ch1[0], "dummy-chan");

            Assert.Equal(eOpStatus.Ok, ret.code);
        }
Ejemplo n.º 8
0
        public void unsubscribe_should_remove_user()
        {
            IBackStore store = new BackStore();

            var data  = UserChannelData().ToList();
            var u2ch1 = data[1];

            foreach (var pair in data)
            {
                store.Subscribe(pair[0], pair[1]);
            }

            Assert.Contains(u2ch1[0], store.ChannelUsers(u2ch1[1]));

            var ret = store.UnSubscribe(u2ch1[0], u2ch1[1]);

            Assert.Equal(eOpStatus.Ok, ret.code);
            Assert.DoesNotContain(u2ch1[0], store.ChannelUsers(u2ch1[1]));
        }