コード例 #1
0
        public void ChannelList()
        {
            List <ChannelInfo> channels = new List <ChannelInfo>
            {
                new ChannelInfo(ChannelId)
                {
                    ReadOnly = true
                },
                new ChannelInfo(ChannelId2)
            };

            var msg = new ChannelListMessage(channels, channels[0]);

            Assert.AreEqual(1, msg.Channels.Count(c => c.ChannelId.Equals(channels[0].ChannelId) && c.ReadOnly == channels[0].ReadOnly));
            Assert.AreEqual(1, msg.Channels.Count(c => c.ChannelId.Equals(channels[1].ChannelId) && c.ReadOnly == channels[1].ReadOnly));
            msg.WritePayload(serverContext, writer);
            long length = stream.Position;

            stream.Position = 0;

            msg = new ChannelListMessage();
            msg.ReadPayload(clientContext, reader);
            Assert.AreEqual(length, stream.Position);
            Assert.AreEqual(1, msg.Channels.Count(c => c.ChannelId.Equals(channels[0].ChannelId) && c.ReadOnly == channels[0].ReadOnly));
            Assert.AreEqual(1, msg.Channels.Count(c => c.ChannelId.Equals(channels[1].ChannelId) && c.ReadOnly == channels[1].ReadOnly));
        }
コード例 #2
0
 private void Network_ChannelListReceived(IrcNetwork network, ChannelListReceivedEventArgs args)
 {
     if (args.Channels.Count == 0)
     {
         var errorText  = Locator.Get <ITranslationService>().Translate("ConversationErrors", "EmptyChannelList");
         var ircMessage = new IrcMessage(this.Network, MessageDirection.FromServer, null, IrcMessageType.Error, errorText);
         this.SelectedConversation.AddMessage(ircMessage);
     }
     else
     {
         var channels = args.Channels.OrderBy(c => c.Name).ToList();
         var message  = new ChannelListMessage(this.Network, channels);
         this.SelectedConversation.AddMessage(message);
     }
 }
コード例 #3
0
        public void ChannelListFailed()
        {
            GenericResult result = GenericResult.FailedPermissions;
            var           msg    = new ChannelListMessage(result);

            Assert.AreEqual(result, msg.Result);
            msg.WritePayload(serverContext, writer);
            long length = stream.Position;

            stream.Position = 0;

            msg = new ChannelListMessage();
            msg.ReadPayload(clientContext, reader);
            Assert.AreEqual(length, stream.Position);
            Assert.AreEqual(result, msg.Result);
        }